diff --git a/src/config.c b/src/config.c index 6fe9391..50ab53f 100644 --- a/src/config.c +++ b/src/config.c @@ -145,6 +145,7 @@ conf_misc_section(char *src) conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool; conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool; conf.status_timing = get_opt(src, "1", "status_timing").num; + conf.status_path = get_opt(src, "", "status_path").str; pad = get_opt(src, "12", "pad").num; if(pad > 24 || pad < 1) diff --git a/src/event.c b/src/event.c index 3aeaa3a..4796327 100644 --- a/src/event.c +++ b/src/event.c @@ -235,7 +235,7 @@ clientmessageevent(XClientMessageEvent *ev) if(mess_t == wmfs_update_status && estatus) - spawn(status_path); + spawn(conf.status_path); return; } diff --git a/src/init.c b/src/init.c index 15d75ec..51026a7 100644 --- a/src/init.c +++ b/src/init.c @@ -184,36 +184,38 @@ init_status(void) struct stat st; char *home; - if(!(home = getenv("HOME"))) + if(!conf.status_path) { - warnx("HOME not set, can't launch status.sh"); - estatus = False; - return; + if(!(home = getenv("HOME"))) + { + warnx("HOME not set, can't launch status.sh"); + estatus = False; + return; + } + + conf.status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char)); + + sprintf(conf.status_path, "%s/"DEF_STATUS, home); } - status_path = emalloc(strlen(home) + strlen(DEF_STATUS) + 2, sizeof(char)); - - sprintf(status_path, "%s/"DEF_STATUS, home); - - if(!(fd = open(status_path, O_RDONLY)) - || !fopen(status_path, "r")) + if(!(fd = open(conf.status_path, O_RDONLY)) + || !fopen(conf.status_path, "r")) { - free(status_path); + free(conf.status_path); estatus = False; return; } - stat(status_path, &st); + stat(conf.status_path, &st); if(st.st_size && st.st_mode & S_IXUSR) { estatus = True; - spawn(status_path); + spawn(conf.status_path); } else - warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.", - status_path); + warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path); close(fd); diff --git a/src/structs.h b/src/structs.h index 70e01a1..a26dacf 100644 --- a/src/structs.h +++ b/src/structs.h @@ -325,6 +325,7 @@ typedef struct Bool focus_fmouse; uint pad; int status_timing; + char *status_path; struct { /* diff --git a/src/wmfs.c b/src/wmfs.c index ab1a792..0af6111 100644 --- a/src/wmfs.c +++ b/src/wmfs.c @@ -154,7 +154,7 @@ thread_process(void *arg) { while(!exiting) { - spawn(status_path); + spawn(conf.status_path); sleep(conf.status_timing); } diff --git a/src/wmfs.h b/src/wmfs.h index 252000e..e3acc50 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -369,7 +369,7 @@ Bool exiting, estatus; XRectangle *sgeo; XRectangle *spgeo; Cursor cursor[CurLast]; -char *argv_global, *status_path; +char *argv_global; int xrandr_event; uint timing;