Conf: Add [misc] status_path option to choose status script path

This commit is contained in:
Martin Duquesnoy 2010-03-25 19:19:24 +01:00
parent 23b0539686
commit c5da009b7a
6 changed files with 22 additions and 18 deletions

View File

@ -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)

View File

@ -235,7 +235,7 @@ clientmessageevent(XClientMessageEvent *ev)
if(mess_t == wmfs_update_status
&& estatus)
spawn(status_path);
spawn(conf.status_path);
return;
}

View File

@ -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);

View File

@ -325,6 +325,7 @@ typedef struct
Bool focus_fmouse;
uint pad;
int status_timing;
char *status_path;
struct
{
/*

View File

@ -154,7 +154,7 @@ thread_process(void *arg)
{
while(!exiting)
{
spawn(status_path);
spawn(conf.status_path);
sleep(conf.status_timing);
}

View File

@ -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;