wmusic: Print message when connecting to new player.
[dockapps.git] / wmusic / src / wmusic.c
blob8f8b6d216dc1912116df83d2d1a2620046e06f98
1 /* wmusic - a xmms remote-controlling DockApp
2 * Copyright (C) 2000-2001 Bastien Nocera <hadess@hadess.net>
3 * Maintained by John Chapin <john+wmusic@jtan.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #define DBL_CLICK_INTERVAL 250 /* double click interval in milliseconds */
21 #define ARROW_INTERVAL 100 /* arrow update interval in milliseconds */
22 #define SCROLL_INTERVAL 300 /* scroll update interval in milliseconds */
23 #define SEPARATOR " ** " /* The separator for the scrolling title */
24 #define DISPLAYSIZE 6 /* width of text to display (running title) */
26 #include <libdockapp/dockapp.h>
27 #include <playerctl/playerctl.h>
28 #include <unistd.h>
29 #include <ctype.h>
30 #include <string.h>
31 #include <locale.h>
33 #include "wmusic-master.xpm"
34 #include "wmusic-digits.xpm"
36 /*---------------------------------------------------------------------------*/
37 /* Prototypes */
38 /*---------------------------------------------------------------------------*/
40 void copyNumArea(int x, int y, int sx, int sy, int dx, int dy);
41 void ActionPlay(int x, int y, DARect rect, void *data);
42 void ActionPause(int x, int y, DARect rect, void *data);
43 void ActionEject(int x, int y, DARect rect, void *data);
44 void ActionPrev(int x, int y, DARect rect, void *data);
45 void ActionNext(int x, int y, DARect rect, void *data);
46 void ActionStop(int x, int y, DARect rect, void *data);
47 void ActionFastr(int x, int y, DARect rect, void *data);
48 void ActionFastf(int x, int y, DARect rect, void *data);
49 void ToggleWins(int x, int y, DARect rect, void *data);
50 void ToggleVol(int x, int y, DARect rect, void *data);
51 void ChangeVol(int x, int y, DARect rect, void *data);
52 void ToggleTime(int x, int y, DARect rect, void *data);
53 void buttonPress(int button, int state, int x, int y);
54 void buttonRelease(int button, int state, int x, int y);
55 int PlayerConnect(void);
56 void DisplayRoutine();
57 void DrawPos (int pos);
58 void DrawTime(int time);
59 void DrawArrow(void);
60 void DrawVolume(void);
61 void DrawTitle(char *title);
62 void ExecuteXmms(void);
64 /*----------------------------------------------------------------------------*/
65 /* Variables */
66 /*----------------------------------------------------------------------------*/
68 /* X11 variables */
69 char *displayName = "";
70 GC gc;
71 XEvent ev;
73 /* Dockapp variables */
74 PlayerctlPlayer *player;
75 char *xmms_cmd = "xmms";
76 Bool main_vis=0, pl_vis=0, eq_vis=0;
77 unsigned int volume_step = 5;
78 Bool run_excusive=0;
80 Bool t_time=0;
81 float title_pos = 0;
82 unsigned int arrow_pos = 0;
83 Bool pause_norotate = 0;
84 Time click_time=0;
86 Pixmap pixmap, mask; /* Pixmap that is displayed */
87 Pixmap pixnum, masknum; /* Pixmap source */
89 int left_pressed = 0; /* for pseudo drag callback */
90 int motion_event = 0; /* on motion events we do not want(too fast) display update */
92 static DAActionRect buttonRects[] = {
93 {{5, 39, 14, 9}, ActionPrev},
94 {{19, 39, 14, 9}, ActionNext},
95 {{33, 39, 13, 9}, ActionFastr},
96 {{46, 39, 13, 9}, ActionFastf},
97 {{5, 48, 11, 11}, ActionEject},
98 {{16, 48, 21, 11}, ActionPlay},
99 {{37, 48, 11, 11}, ActionPause},
100 {{48, 48, 11, 11}, ActionStop}
103 static DAActionRect toggleRect[] = {
104 {{5, 5, 54, 30}, ToggleWins}
107 static DAActionRect globRect[] = {
108 {{0, 0, 64, 64}, ToggleVol}
111 static DAActionRect displayRects[] = {
112 {{5, 5, 54, 12}, ToggleTime},
115 static DAActionRect volumeRects[] = {
116 {{5, 17, 38, 8 }, ChangeVol}
119 static DAProgramOption options[] = {
120 {"-c", "--command", "Command to launch xmms", DOString, False,
121 {&xmms_cmd} },
122 {"-d", "--display", "Display to use", DOString, False, {&displayName} },
123 {"-r", "--run", "Run xmms on startup", DONone, False, {NULL} },
124 {"-V", "--volume", "Stepping of the wheel volume control (in percent)",
125 DONatural, False, {&volume_step} },
126 {"-a", "--rotate-arrow", "Do not rotate the arrow, when paused",
127 DONone, False, {NULL} },
128 {"-l", "--time-left", "Show time left instead of time remaining by default",
129 DONone, False, {NULL} },
130 {"-R", "--run-excusive", "Run xmms on startup, exit when xmms exits", DONone, False, {NULL} }
133 typedef struct
135 wchar_t c;
136 int x;
137 int y;
138 } glyphdescr;
140 static glyphdescr glyphs[] = {
141 {L'-', 67, 83}, {L'.', 73, 83}, {L'\x27', 79, 83},
142 {L'(', 85, 83}, {L')', 91, 83}, {L'*', 97, 83}, {L'/', 103, 83},
144 {L'0', 1, 83}, {L'1', 7, 83}, {L'2', 13, 83}, {L'3', 19, 83}, {L'4', 25, 83},
145 {L'5', 31, 83}, {L'6', 37, 83}, {L'7', 43, 83}, {L'8', 49, 83}, {L'9', 55, 83},
149 {L'A', 1, 73}, {L'a', 1, 73},
150 {L'B', 7, 73}, {L'b', 7, 73},
151 {L'C', 13, 73}, {L'c', 13, 73},
152 {L'D', 19, 73}, {L'd', 19, 73},
153 {L'E', 25, 73}, {L'e', 25, 73},
155 {L'F', 31, 73}, {L'f', 31, 73},
156 {L'G', 37, 73}, {L'g', 37, 73},
157 {L'H', 43, 73}, {L'h', 43, 73},
158 {L'I', 49, 73}, {L'i', 49, 73},
159 {L'J', 55, 73}, {L'j', 55, 73},
161 {L'K', 61, 73}, {L'k', 61, 73},
162 {L'L', 67, 73}, {L'l', 67, 73},
163 {L'M', 73, 73}, {L'm', 73, 73},
164 {L'N', 79, 73}, {L'n', 79, 73},
165 {L'O', 85, 73}, {L'o', 85, 73},
167 {L'P', 91, 73}, {L'p', 91, 73},
168 {L'Q', 97, 73}, {L'q', 97, 73},
169 {L'R',103, 73}, {L'r',103, 73},
170 {L'S',109, 73}, {L's',109, 73},
171 {L'T',115, 73}, {L't',115, 73},
173 {L'U',121, 73}, {L'u',121, 73},
174 {L'V',127, 73}, {L'v',127, 73},
175 {L'W',133, 73}, {L'w',133, 73},
176 {L'X',139, 73}, {L'x',139, 73},
177 {L'Y',145, 73}, {L'y',145, 73},
179 {L'Z',151, 73}, {L'z',151, 73},
182 {L'\x42e', 1, 93}, {L'\x44e', 1, 93}, /* cyrillic Yu */
184 {L'\x410', 7, 93}, {L'\x430', 7, 93}, /* cyrillic A */
185 {L'\x411', 13, 93}, {L'\x431', 13, 93}, /* cyrillic Be */
186 {L'\x426', 19, 93}, {L'\x446', 19, 93}, /* cyrillic Ce */
187 {L'\x414', 25, 93}, {L'\x434', 25, 93}, /* cyrillic De */
188 {L'\x415', 31, 93}, {L'\x435', 31, 93}, /* cyrillic Ye */
190 {L'\x424', 37, 93}, {L'\x444', 37, 93}, /* cyrillic eF */
191 {L'\x413', 43, 93}, {L'\x433', 43, 93}, /* cyrillic Ge */
192 {L'\x425', 49, 93}, {L'\x445', 49, 93}, /* cyrillic Ha */
193 {L'\x418', 55, 93}, {L'\x438', 55, 93}, /* cyrillic I */
194 {L'\x419', 61, 93}, {L'\x439', 61, 93}, /* cyrillic I-kratkoe */
196 {L'\x41a', 67, 93}, {L'\x43a', 67, 93}, /* cyrillic Ka */
197 {L'\x41b', 73, 93}, {L'\x43b', 73, 93}, /* cyrillic eL */
198 {L'\x41c', 79, 93}, {L'\x43c', 79, 93}, /* cyrillic eM */
199 {L'\x41d', 85, 93}, {L'\x43d', 85, 93}, /* cyrillic eN */
200 {L'\x41e', 91, 93}, {L'\x43e', 91, 93}, /* cyrillic O */
202 {L'\x41f', 97, 93}, {L'\x43f', 97, 93}, /* cyrillic Pe */
203 {L'\x42f',103, 93}, {L'\x44f',103, 93}, /* cyrillic Ya */
204 {L'\x420',109, 93}, {L'\x440',109, 93}, /* cyrillic eR */
205 {L'\x421',115, 93}, {L'\x441',115, 93}, /* cyrillic eS */
206 {L'\x422',121, 93}, {L'\x442',121, 93}, /* cyrillic Te */
208 {L'\x423',127, 93}, {L'\x443',127, 93}, /* cyrillic U */
209 {L'\x416',133, 93}, {L'\x436',133, 93}, /* cyrillic Je */
210 {L'\x412',139, 93}, {L'\x432',139, 93}, /* cyrillic Ve */
211 {L'\x42c',145, 93}, {L'\x44c',145, 93}, /* cyrillic MyagkijZnak */
212 {L'\x42b',151, 93}, {L'\x44b',151, 93}, /* cyrillic Y */
214 {L'\x417',157, 93}, {L'\x437',157, 93}, /* cyrillic Ze */
215 {L'\x428',163, 93}, {L'\x448',163, 93}, /* cyrillic Sha */
216 {L'\x42d',169, 93}, {L'\x44d',169, 93}, /* cyrillic E */
217 {L'\x429',175, 93}, {L'\x449',175, 93}, /* cyrillic Scha */
218 {L'\x427',181, 93}, {L'\x447',181, 93}, /* cyrillic Che */
220 {L'\x42a',187, 93}, {L'\x44a',187, 93}, /* cyrillic TvyordyiZnak */
221 {L'\x404',115, 83}, {L'\x454',115, 83}, /* ukrainian IE */
222 {L'\x406', 49, 73}, {L'\x456', 49, 73}, /* ukrainian I */
223 {L'\x407',109, 83}, {L'\x457',109, 83}, /* ukrainian YI */
224 {L'\x491', 43, 93}, {L'\x490', 43, 93}, /* ukrainian GHE with upturn */
226 {L'\x401',121, 83}, {L'\x451',121, 83}, /* cyrillic Yo */
228 {L' ', 61, 83}
231 /*----------------------------------------------------------------------------*/
232 /* Functions */
233 /*----------------------------------------------------------------------------*/
235 void copyNumArea(int x, int y, int sx, int sy, int dx, int dy)
237 XCopyArea(DADisplay, pixnum, pixmap, gc, x, y, sx, sy, dx, dy);
240 void buttonDraw(DARect rect)
242 copyNumArea((rect.x)-5, (rect.y)-8, rect.width, rect.height,
243 rect.x, rect.y);
244 DASetPixmap(pixmap);
247 void ActionPlay(int x, int y, DARect rect, void *data)
249 if (data) {
250 buttonDraw(rect);
251 } else {
252 GError *error = NULL;
254 playerctl_player_play(player, &error);
255 if (error != NULL)
256 DAWarning("Could not execute command: %s",
257 error->message);
261 void ActionPause(int x, int y, DARect rect, void *data)
263 if (data) {
264 buttonDraw(rect);
265 } else {
266 GError *error = NULL;
268 playerctl_player_pause(player, &error);
269 if (error != NULL)
270 DAWarning("Could not execute command: %s",
271 error->message);
275 void ActionEject(int x, int y, DARect rect, void *data)
277 if (data) {
278 buttonDraw(rect);
279 } else {
280 DAWarning("Eject function is no longer supported.");
284 void ActionPrev(int x, int y, DARect rect, void *data)
286 if (data) {
287 buttonDraw(rect);
288 } else {
289 GError *error = NULL;
291 playerctl_player_previous(player, &error);
292 if (error != NULL)
293 DAWarning("Could not execute command: %s",
294 error->message);
298 void ActionNext(int x, int y, DARect rect, void *data)
300 if (data) {
301 buttonDraw(rect);
302 } else {
303 GError *error = NULL;
305 playerctl_player_next(player, &error);
306 if (error != NULL)
307 DAWarning("Could not execute command: %s",
308 error->message);
312 void ActionStop(int x, int y, DARect rect, void *data)
314 if (data) {
315 buttonDraw(rect);
316 } else {
317 GError *error = NULL;
319 playerctl_player_stop(player, &error);
320 if (error != NULL)
321 DAWarning("Could not execute command: %s",
322 error->message);
326 void ActionFastr(int x, int y, DARect rect, void *data)
328 if (data) {
329 buttonDraw(rect);
330 } else {
331 GError *error = NULL;
333 playerctl_player_seek(player, -10000000, &error);
334 if (error != NULL)
335 DAWarning("Could not execute command: %s",
336 error->message);
340 void ActionFastf(int x, int y, DARect rect, void *data)
342 if (data) {
343 buttonDraw(rect);
344 } else {
345 GError *error = NULL;
347 playerctl_player_seek(player, 10000000, &error);
348 if (error != NULL)
349 DAWarning("Could not execute command: %s",
350 error->message);
354 void ToggleWins(int x, int y, DARect rect, void *data)
356 if (!player) {
357 if ( (ev.xbutton.time-click_time) <= DBL_CLICK_INTERVAL )
359 click_time=0;
360 ExecuteXmms();
361 } else {
362 click_time=ev.xbutton.time;
367 void ToggleVol(int x, int y, DARect rect, void *data)
369 double volume;
370 double factor;
372 g_object_get(player, "volume", &volume, NULL);
374 if (*(int*)data == 1)
375 factor = 0.01 * volume_step;
376 else
377 factor = -0.01 * volume_step;
378 volume += factor;
380 if (volume > 1)
381 volume = 1;
382 if (volume < 0)
383 volume = 0;
385 g_object_set(player, "volume", volume, NULL);
388 void ChangeVol(int x, int y, DARect rect, void *data)
390 float volume = ((float)x)/38;
391 g_object_set(player, "volume", volume, NULL);
394 void ToggleTime(int x, int y, DARect rect, void *data)
396 if (t_time)
397 t_time = 0;
398 else t_time =1;
401 void buttonPress(int button, int state, int x, int y)
403 if (button==1)
404 left_pressed=1;
405 if (player)
407 if (button == 1)
409 char *tmp="1";
410 DAProcessActionRects(x, y, buttonRects, sizeof(buttonRects)/sizeof(DAActionRect), tmp);
411 DAProcessActionRects(x, y, displayRects, sizeof(displayRects)/sizeof(DAActionRect), tmp);
413 if (button == 2)
415 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), NULL);
417 if (button == 3)
419 char *tmp="1";
420 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), tmp);
422 if ((button == 4) || (button == 5))
424 if (button == 5)
426 /* Wheel scrolls down */
427 int tmp=2;
428 DAProcessActionRects(x, y, globRect, sizeof(globRect)/sizeof(DAActionRect), &tmp);
429 } else {
430 /* Wheel scrolls up */
431 int tmp=1;
432 DAProcessActionRects(x, y, globRect, sizeof(globRect)/sizeof(DAActionRect), &tmp);
436 else
437 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), NULL);
440 void buttonRelease(int button, int state, int x, int y)
442 if (button==1)
443 left_pressed=0;
444 if (player)
446 if (button == 1)
448 copyNumArea(0,51, 54, 20, 5,39);
449 DASetPixmap(pixmap);
450 DAProcessActionRects(x, y, buttonRects, sizeof(buttonRects)/sizeof(DAActionRect), NULL);
455 void buttonDrag(int x, int y)
457 motion_event=1;
458 if (left_pressed==1) {
459 DAProcessActionRects(x,y, volumeRects, 1, NULL);
460 DrawVolume();
461 DASetPixmap(pixmap);
465 int PlayerConnect(void)
467 GError *error = NULL;
468 static int previous_error_code = 0;
469 static char* player_name = NULL;
471 player = playerctl_player_new(NULL, &error);
472 if (error != NULL) {
473 /* don't spam error message */
474 if (error->code != previous_error_code)
475 DAWarning("Connection to player failed: %s",
476 error->message);
477 previous_error_code = error->code;
478 player_name = NULL;
479 return 0;
480 } else {
481 previous_error_code = 0;
482 if (!player_name) {
483 g_object_get(player, "player_name", &player_name, NULL);
484 player_name++; /* get rid of opening dot */
485 if (player_name)
486 DAWarning("Connected to %s", player_name);
488 return 1;
492 void DisplayRoutine()
494 int time = 0, length = 0, position = 100;
495 char *title = NULL;
496 GError *error = NULL;
498 PlayerConnect();
500 /* Compute diplay */
501 if (!player)
503 if (run_excusive)
504 exit(0);
505 title = strdup("--");
506 title_pos = 0;
507 arrow_pos = 5;
508 } else {
509 char *length_str, *position_str, *status;
511 g_object_get(player, "status", &status, NULL);
512 if (status) {
513 if (!strcmp(status, "Playing") ||
514 !strcmp(status, "Paused")) {
515 g_object_get(player, "position", &time, NULL);
517 title = playerctl_player_get_title(player,
518 &error);
519 if (error != NULL)
520 DAWarning("%s", error->message);
522 length_str =
523 playerctl_player_print_metadata_prop(
524 player, "mpris:length", &error);
525 if (error != NULL)
526 DAWarning("%s", error->message);
527 if (length_str)
528 length = atoi(length_str);
529 else
530 length = 0;
532 position_str =
533 playerctl_player_print_metadata_prop(
534 player, "xesam:trackNumber",
535 &error);
536 if (error != NULL)
537 DAWarning("%s", error->message);
538 if (position_str)
539 position = atoi(position_str);
540 else
541 position = 0;
543 if (!strcmp(status, "Paused") && pause_norotate)
544 arrow_pos = 5;
545 } else { /* not playing or paused */
546 title = strdup("--");
547 title_pos = 0;
548 arrow_pos = 5;
551 } else { /* status undefined */
552 title = strdup("--");
553 title_pos = 0;
554 arrow_pos = 5;
558 /*Draw everything */
559 if (t_time && length) DrawTime((length-time) / 1000);
560 else DrawTime(time / 1000);
561 DrawPos(position);
562 DrawArrow();
563 DrawVolume();
564 DrawTitle(title);
566 DASetPixmap(pixmap);
568 if (title != NULL)
569 free(title);
572 void DrawPos (int pos)
574 char posstr[16];
575 char *p = posstr;
576 int i=1;
578 if (pos > 99) pos=0;
579 sprintf(posstr, "%02d", pos);
581 for (;i<3; i++)
583 copyNumArea((*p-'0')*6 + 1, 1, 6, 7, (i*6)+39, 7);
584 p++;
588 void DrawTime(int time)
590 char timestr[16];
591 char *p = timestr;
592 int i=0;
594 time = time / 1000;
596 /* 3 cases:
597 * up to 99 minutes and 59 seconds
598 * up to 99 hours and 59 minutes
599 * more
601 if (time < 6000)
603 sprintf(timestr, "%02d%02d", time / 60, time % 60);
604 } else {
605 if (time < 360000)
607 sprintf(timestr, "%02d%02d", time / 3600,
608 time % 3600 / 60);
609 } else {
610 sprintf(timestr, "%02d%02d", 0, 0);
614 for (;i<4; i++)
616 copyNumArea((*p-'0')*7 + 2, 11, 7, 9, i<2 ?(i*7)+7:(i*7)+12, 7);
617 p++;
621 void DrawArrow(void)
623 copyNumArea((arrow_pos*8)+30, 22, 8, 9, 47, 19);
624 arrow_pos++;
625 if (arrow_pos > 4) arrow_pos = 0;
628 void DrawVolume(void)
630 int volume;
631 double volume_double;
633 g_object_get(player, "volume", &volume_double, NULL);
634 volume = (int)(36 * volume_double);
635 if (volume > 36)
636 volume = 36;
637 copyNumArea(61, 0, volume, 6, 7, 18);
638 copyNumArea(97, 0, 36-volume, 6, 7+volume, 18);
641 void DrawKbps(int bps)
643 char kbpstr[16];
644 char *p = kbpstr;
645 int i=1;
647 if (bps > 999000) bps=0;
648 sprintf(kbpstr, "%03d", bps / 1000);
650 for (;i<4; i++)
652 copyNumArea((*p-'0')*6 + 1, 1, 6, 7, (i*6)+1, 26);
653 p++;
655 copyNumArea(55, 39, 18, 8, 25, 26);
658 void DrawChar(wchar_t wc, int x, int y)
660 int i;
661 for(i = 0; i < sizeof(glyphs)/sizeof(glyphdescr) - 1; ++i)
663 if(wc == glyphs[i].c)
664 break;
666 copyNumArea(glyphs[i].x, glyphs[i].y, 6, 8, x, y);
669 int DrawChars(char *title, int tpos, int pos)
671 wchar_t wc;
673 mbtowc(NULL, NULL, 0);
674 while(*title && (pos <= (tpos + DISPLAYSIZE)))
676 int len = mbtowc(&wc, title, MB_CUR_MAX);
677 title += len;
678 if(pos >= tpos)
679 DrawChar(wc, (pos - tpos)*6 + 7, 26);
680 ++pos;
682 return pos;
685 void DrawTitle(char *name)
687 int len, pos, tpos = title_pos;
689 if (name == NULL)
690 return;
692 len = pos = DrawChars(name, tpos, 0);
694 if(pos < 6)
696 DrawChars(" ", tpos, pos);
697 return;
700 if(pos <= tpos + DISPLAYSIZE)
701 pos = DrawChars(SEPARATOR, tpos, pos);
703 if(pos <= tpos + DISPLAYSIZE)
704 DrawChars(name, tpos, pos);
706 if(tpos >= len + strlen(SEPARATOR))
707 title_pos = 0;
709 title_pos = title_pos + 0.5;
712 void ExecuteXmms(void)
714 char *command;
715 int status;
717 command=malloc(strlen(xmms_cmd)+5);
718 sprintf(command, "%s &", xmms_cmd);
719 status = system(command);
720 if (status)
722 fprintf(stderr, "XMMS can't be launched, exiting...");
723 exit(1);
725 while (!PlayerConnect())
726 usleep(10000L);
727 free(command);
729 /*----------------------------------------------------------------------------*/
730 /* Main */
731 /*----------------------------------------------------------------------------*/
733 int main(int argc, char **argv)
735 short unsigned int height, width;
736 DACallbacks callbacks={NULL, buttonPress, buttonRelease, buttonDrag,
737 NULL, NULL, NULL};
739 /* Initialization */
740 DAParseArguments(argc, argv, options,
741 sizeof(options)/sizeof(DAProgramOption),
742 "XMMS remote control by Bastien Nocera <hadess@hadess.net>",
743 PACKAGE_STRING);
745 setlocale(LC_ALL, "");
746 DAInitialize(displayName, "wmusic", 64, 64, argc, argv);
747 DASetCallbacks(&callbacks);
748 DASetTimeout(100);
750 DAMakePixmapFromData(wmusic_master_xpm, &pixmap,
751 &mask, &height, &width);
752 DAMakePixmapFromData(wmusic_digits_xpm, &pixnum,
753 &masknum, &height, &width);
754 gc = DefaultGC(DADisplay, DefaultScreen(DADisplay));
755 DASetShapeWithOffset(mask, 0, 0);
757 DASetPixmap(pixmap);
758 DAShow();
760 /* End of initialization */
762 if (options[4].used) pause_norotate=1;
763 if (options[5].used) t_time=1;
764 if (options[6].used) run_excusive=1;
766 PlayerConnect();
768 /* Launch xmms if it's not running and -r or -R was used */
769 if ((!player) && (options[2].used || run_excusive))
771 ExecuteXmms();
774 /* Update the display */
775 DisplayRoutine();
777 while (1) {
778 if (DANextEventOrTimeout(&ev, 100))
779 DAProcessEvent(&ev);
780 if (!motion_event)
781 DisplayRoutine();
782 else
783 motion_event=0;
785 return 0;