diff --git a/01_git/astime.c b/01_git/astime.c index b13c86ebbcad672c0960a8b97959e8808e05a77e..e331635209717def24d03049fb5b39cf04cb85a9 100644 --- a/01_git/astime.c +++ b/01_git/astime.c @@ -71,6 +71,8 @@ void defaults() state.twentyfour = 0; state.sunriset = 0; state.counterclockwise = 0; + state.lon = 49.6972222; + state.lat = 11.05; withdrawn = 0; iconic = 0; pushed_in = 1; @@ -99,6 +101,9 @@ void defaults() safecopy(state.ampmcolor, "#a0a0a0", MAX_OPT_LEN); safecopy(state.datecolor, "#a0a0a0", MAX_OPT_LEN); + safecopy(state.sunrisetday, "#ffa800", MAX_OPT_LEN); + safecopy(state.sunrisetnight, "#000000", MAX_OPT_LEN); + /* label options */ state.show_label = 0; state.label_top = 0; @@ -167,6 +172,10 @@ void usage() printf("-ltop the label should go on top\n"); printf("-24 use 24 hour mode\n"); printf("-srt show sunrise and sunset times\n"); + printf("-lon geographical longitude\n"); + printf("-lat geographical latitude\n"); + printf("-srtd <color> srt day color\n"); + printf("-srtn <color> srt night color\n"); printf("-cc use counter clockwise mode\n"); printf("\n"); exit(0); @@ -405,6 +414,10 @@ void parsercfile(FILE * ifp) tval = atoi(param[1]); if (tval) state.sunriset = 1; + } else if (!strcmp(param[0], "sunrisetDay")) { + safecopy(state.sunrisetday, param[1], MAX_OPT_LEN); + } else if (!strcmp(param[0], "sunrisetNight")) { + safecopy(state.sunrisetnight, param[1], MAX_OPT_LEN); } else if (!strcmp(param[0], "counterclockwise")) { tval = atoi(param[1]); if (tval) @@ -514,6 +527,14 @@ void parsecmdline(int argc, char *argv[]) if (++i >= argc) usage(); safecopy(state.datecolor, argv[i], MAX_OPT_LEN); + } else if (!strncmp(argument, "-srtd", 5)) { + if (++i >= argc) + usage(); + safecopy(state.sunrisetday, argv[i], MAX_OPT_LEN); + } else if (!strncmp(argument, "-srtn", 5)) { + if (++i >= argc) + usage(); + safecopy(state.sunrisetnight, argv[i], MAX_OPT_LEN); } else if (!strncmp(argument, "-exe", 4)) { if (++i >= argc) usage(); @@ -559,7 +580,7 @@ void parsecmdline(int argc, char *argv[]) usage(); } else if (!strncmp(argument, "-24", 3)) { state.twentyfour = 1; - } else if (!strncmp(argument, "-srt", 3)) { + } else if (!strncmp(argument, "-srt", 4)) { state.sunriset = 1; } else if (!strncmp(argument, "-cc", 3)) { state.counterclockwise = 1; diff --git a/01_git/astime_x.c b/01_git/astime_x.c index 556eedeb7aa4fda8fa258132aef09c0876acf184..abe82b6d47af7bfb322f5394adcfc0013ad158d4 100644 --- a/01_git/astime_x.c +++ b/01_git/astime_x.c @@ -9,8 +9,6 @@ * This software is distributed under GPL. For details see LICENSE file. */ -#define DEBUG - #define CIVIL_TWILIGHT 1 #define NAUT_TWILIGHT 2 #define ASTRO_TWILIGHT 3 @@ -77,6 +75,7 @@ char digits_pixmap_color[2][32]; char months_pixmap_color[2][32]; Pixel back_pix, fore_pix; +Pixel day_pix, night_pix, astro_pix, naut_pix; /* The center of the clock */ struct coordinates center; @@ -330,13 +329,13 @@ void draw_window(Window win) /* draw sunrise and sunset */ if (state.twentyfour && state.sunriset) { draw_sunriset(win, loc_time, - 49.6972222, 11.05, pix[2], SUNRISET_SIZE, DARKNESS); + state.lon, state.lat, night_pix, SUNRISET_SIZE, DARKNESS); draw_sunriset(win, loc_time, - 49.6972222, 11.05, pix[4], SUNRISET_SIZE, ASTRO_TWILIGHT); + state.lon, state.lat, astro_pix, SUNRISET_SIZE, ASTRO_TWILIGHT); draw_sunriset(win, loc_time, - 49.6972222, 11.05, pix[6], SUNRISET_SIZE, NAUT_TWILIGHT); + state.lon, state.lat, naut_pix, SUNRISET_SIZE, NAUT_TWILIGHT); draw_sunriset(win, loc_time, - 49.6972222, 11.05, pix[3], SUNRISET_SIZE, CIVIL_TWILIGHT); + state.lon, state.lat, day_pix, SUNRISET_SIZE, CIVIL_TWILIGHT); } /* draw filled polygonal hands */ for (i = 2; i >= 0; i--) { @@ -841,6 +840,12 @@ void initialize(int argc, char **argv, Root = RootWindow(mainDisplay, screen); back_pix = GetColor(state.bgcolor, mainDisplay, Root); fore_pix = GetColor(state.fgcolor, mainDisplay, Root); + day_pix = GetColor(state.sunrisetday, mainDisplay, Root); + night_pix = GetColor(state.sunrisetnight, mainDisplay, Root); + naut_pix = MixColors(state.sunrisetday, + state.sunrisetnight, .6, mainDisplay, Root); + astro_pix = MixColors(state.sunrisetday, + state.sunrisetnight, .3, mainDisplay, Root); color_depth = DefaultDepth(mainDisplay, screen); #ifdef DEBUG printf("astime : detected color depth %d bpp, using %d bpp\n", diff --git a/01_git/configure b/01_git/configure index 3387e61cb15309bfb38031363c6ab8a74ceb22be..76bd737d1891cd0da01ba4c5be2ed97ddaa5e3b2 100755 --- a/01_git/configure +++ b/01_git/configure @@ -823,13 +823,13 @@ if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then - CFLAGS="-g -O2" + CFLAGS="-g -O3" else CFLAGS="-g" fi else if test "$GCC" = yes; then - CFLAGS="-O2" + CFLAGS="-O3" else CFLAGS= fi diff --git a/01_git/state.h b/01_git/state.h index b85eb0a710b6315e3655c950eb75c1775b361dba..1f53e377268ca74c40e62ca0cccdf2858ef872ef 100644 --- a/01_git/state.h +++ b/01_git/state.h @@ -55,6 +55,7 @@ struct astime_state { unsigned short int cron_program; unsigned short int twentyfour; unsigned short int sunriset; + double lon, lat; unsigned short int counterclockwise; /* main colors */ @@ -76,6 +77,9 @@ struct astime_state { char daycolor[MAX_OPT_LEN]; char ampmcolor[MAX_OPT_LEN]; char datecolor[MAX_OPT_LEN]; + /* day and night color */ + char sunrisetday[MAX_OPT_LEN]; + char sunrisetnight[MAX_OPT_LEN]; unsigned int show_label; /* Show a user-specified label */ unsigned int label_top; /* If the label is on top or at the bottom */