diff options
Diffstat (limited to 'dwmtimestatus.c')
| -rw-r--r-- | dwmtimestatus.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/dwmtimestatus.c b/dwmtimestatus.c index 044e9e7..d61b074 100644 --- a/dwmtimestatus.c +++ b/dwmtimestatus.c @@ -22,13 +22,8 @@ struct status{ }; struct sigaction *s_act = NULL; -struct status current_status = {0}; -XTextProperty status_props = { - .value = (unsigned char*)¤t_status.status, - .encoding = XA_STRING, - .format = 8, - .nitems = 0 -}; +struct status *current_status_ptr = NULL; +XTextProperty *status_props_ptr = NULL; void sighandler( int si_code, siginfo_t *si_info, void *si_adr ){ int exit_status = EXIT_SUCCESS; @@ -40,13 +35,12 @@ void sighandler( int si_code, siginfo_t *si_info, void *si_adr ){ { fprintf( stdout, "Received signal %i, exiting\n", si_code ); } - if ( current_status.dpy != NULL ){ - if ( XCloseDisplay(current_status.dpy) == BadGC ) + if ( current_status_ptr->dpy != NULL ){ + if ( XCloseDisplay(current_status_ptr->dpy) == BadGC ) fputs( "XCloseDisplay returned BadGC error\n", stderr ); - current_status.dpy = NULL; + current_status_ptr->dpy = NULL; } - memset( (void*)¤t_status, 0, sizeof(struct status) ); - memset( (void*)&status_props, 0, sizeof(XTextProperty) ); + memset( (void*)status_props_ptr, 0, sizeof(*status_props_ptr) ); free( s_act ); s_act = NULL; exit( exit_status ); @@ -107,7 +101,14 @@ int main( int argc, char **args ){ assert( sigaction(SIGINT, (const struct sigaction*)s_act, NULL) != -1 ); assert( sigaction(SIGTERM, (const struct sigaction*)s_act, NULL) != -1 ); assert( sigaction(SIGPIPE, (const struct sigaction*)s_act, NULL) != -1 ); + struct status current_status = {0}; memset( (void*)¤t_status, 0, sizeof(struct status) ); + XTextProperty status_props = { + .value = (unsigned char*)¤t_status.status, + .encoding = XA_STRING, + .format = 8, + .nitems = 0 + }; const char *optstring = "i:d:f:"; int opt_char = 0; while ( (opt_char = getopt(argc, args, optstring)) != -1 ){ @@ -129,6 +130,8 @@ int main( int argc, char **args ){ } } current_status.root = DefaultRootWindow( current_status.dpy ); + current_status_ptr = ¤t_status; + status_props_ptr = &status_props; status_update_loop( ¤t_status, &status_props ); exit( EXIT_SUCCESS ); } |
