Conf: Add [misc] status_path option to choose status script path
This commit is contained in:
parent
23b0539686
commit
c5da009b7a
@ -145,6 +145,7 @@ conf_misc_section(char *src)
|
|||||||
conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool;
|
conf.raiseswitch = get_opt(src, "false", "raiseswitch").bool;
|
||||||
conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool;
|
conf.focus_fmouse = get_opt(src, "true", "focus_follow_mouse").bool;
|
||||||
conf.status_timing = get_opt(src, "1", "status_timing").num;
|
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;
|
pad = get_opt(src, "12", "pad").num;
|
||||||
|
|
||||||
if(pad > 24 || pad < 1)
|
if(pad > 24 || pad < 1)
|
||||||
|
|||||||
@ -235,7 +235,7 @@ clientmessageevent(XClientMessageEvent *ev)
|
|||||||
|
|
||||||
if(mess_t == wmfs_update_status
|
if(mess_t == wmfs_update_status
|
||||||
&& estatus)
|
&& estatus)
|
||||||
spawn(status_path);
|
spawn(conf.status_path);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/init.c
32
src/init.c
@ -184,36 +184,38 @@ init_status(void)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
char *home;
|
char *home;
|
||||||
|
|
||||||
if(!(home = getenv("HOME")))
|
if(!conf.status_path)
|
||||||
{
|
{
|
||||||
warnx("HOME not set, can't launch status.sh");
|
if(!(home = getenv("HOME")))
|
||||||
estatus = False;
|
{
|
||||||
return;
|
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));
|
if(!(fd = open(conf.status_path, O_RDONLY))
|
||||||
|
|| !fopen(conf.status_path, "r"))
|
||||||
sprintf(status_path, "%s/"DEF_STATUS, home);
|
|
||||||
|
|
||||||
if(!(fd = open(status_path, O_RDONLY))
|
|
||||||
|| !fopen(status_path, "r"))
|
|
||||||
{
|
{
|
||||||
free(status_path);
|
free(conf.status_path);
|
||||||
estatus = False;
|
estatus = False;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stat(status_path, &st);
|
stat(conf.status_path, &st);
|
||||||
|
|
||||||
if(st.st_size && st.st_mode & S_IXUSR)
|
if(st.st_size && st.st_mode & S_IXUSR)
|
||||||
{
|
{
|
||||||
estatus = True;
|
estatus = True;
|
||||||
spawn(status_path);
|
spawn(conf.status_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
warnx("status.sh file present in wmfs directory can't be executed, try 'chmod +x %s'.",
|
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", conf.status_path);
|
||||||
status_path);
|
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
|||||||
@ -325,6 +325,7 @@ typedef struct
|
|||||||
Bool focus_fmouse;
|
Bool focus_fmouse;
|
||||||
uint pad;
|
uint pad;
|
||||||
int status_timing;
|
int status_timing;
|
||||||
|
char *status_path;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -154,7 +154,7 @@ thread_process(void *arg)
|
|||||||
{
|
{
|
||||||
while(!exiting)
|
while(!exiting)
|
||||||
{
|
{
|
||||||
spawn(status_path);
|
spawn(conf.status_path);
|
||||||
sleep(conf.status_timing);
|
sleep(conf.status_timing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -369,7 +369,7 @@ Bool exiting, estatus;
|
|||||||
XRectangle *sgeo;
|
XRectangle *sgeo;
|
||||||
XRectangle *spgeo;
|
XRectangle *spgeo;
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
char *argv_global, *status_path;
|
char *argv_global;
|
||||||
int xrandr_event;
|
int xrandr_event;
|
||||||
uint timing;
|
uint timing;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user