X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fclock%2Fclock.c;h=a3061cb206919800ae04c1d4b0eb38c8e24b66d7;hb=11c177f708dc4f9cb0762050e3e376ced0272fd7;hp=288ed942e601181bdb2792fe7fe9f7889c4ea32f;hpb=2e6b12080e5187b0e0db377cd4df22405119e5b8;p=chaz%2Ftint2 diff --git a/src/clock/clock.c b/src/clock/clock.c index 288ed94..a3061cb 100644 --- a/src/clock/clock.c +++ b/src/clock/clock.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "window.h" #include "server.h" @@ -31,8 +32,10 @@ #include "clock.h" -char *time1_format = 0; -char *time2_format = 0; +char *time1_format; +char *time2_format; +char *clock_lclick_command; +char *clock_rclick_command; struct timeval time_clock; int time_precision; PangoFontDescription *time1_font_desc; @@ -41,6 +44,16 @@ static char buf_time[40]; static char buf_date[40]; +void init_precision() +{ + if (!time1_format) time_precision = 60; + else if (strchr(time1_format, 'S')) time_precision = 1; + else if (strchr(time1_format, 'T')) time_precision = 1; + else if (strchr(time1_format, 'r')) time_precision = 1; + else time_precision = 60; +} + + void init_clock() { Panel *panel; @@ -55,11 +68,7 @@ void init_clock() clock->area.panel = panel; clock->area._draw_foreground = draw_clock; clock->area._resize = resize_clock; - - if (!clock->area.on_screen) continue; - - if (strchr(time1_format, 'S') == NULL) time_precision = 60; - else time_precision = 1; + init_precision(); // update clock to force update (-time_precision) struct timeval stv; @@ -67,6 +76,8 @@ void init_clock() time_clock.tv_sec = stv.tv_sec - time_precision; time_clock.tv_sec -= time_clock.tv_sec % time_precision; + if (!clock->area.on_screen) continue; + clock->area.posy = panel->area.pix.border.width + panel->area.paddingy; clock->area.height = panel->area.height - (2 * clock->area.posy); clock->area.resize = 1; @@ -187,3 +198,25 @@ void resize_clock (void *obj) XFreePixmap (server.dsp, pmap); } + +void clock_action(int button) +{ + char *command = 0; + switch (button) { + case 1: + command = clock_lclick_command; + break; + case 3: + command = clock_rclick_command; + break; + } + if (command) { + pid_t pid; + pid = fork(); + if (pid == 0) { + execl("/bin/sh", "/bin/sh", "-c", command, NULL); + _exit(0); + } + } +} +