Status: Remove status management (status_path, status_timing, threading), use loop in status script now (see scripts/status.sh)
This commit is contained in:
parent
7bfba91a92
commit
4e33bc9bf7
@ -8,4 +8,4 @@ statustext()
|
|||||||
wmfs -s "`date`"
|
wmfs -s "`date`"
|
||||||
}
|
}
|
||||||
|
|
||||||
statustext
|
while true; do statustext; sleep 10; done
|
||||||
|
|||||||
@ -183,8 +183,6 @@ conf_misc_section(void)
|
|||||||
conf.focus_fmouse = fetch_opt_first(sec, "true", "focus_follow_mouse").boolean;
|
conf.focus_fmouse = fetch_opt_first(sec, "true", "focus_follow_mouse").boolean;
|
||||||
conf.focus_fmov = fetch_opt_first(sec, "false", "focus_follow_movement").boolean;
|
conf.focus_fmov = fetch_opt_first(sec, "false", "focus_follow_movement").boolean;
|
||||||
conf.focus_pclick = fetch_opt_first(sec, "true", "focus_pointer_click").boolean;
|
conf.focus_pclick = fetch_opt_first(sec, "true", "focus_pointer_click").boolean;
|
||||||
conf.status_timing = fetch_opt_first(sec, "1", "status_timing").num;
|
|
||||||
conf.status_path = fetch_opt_first(sec, "", "status_path").str;
|
|
||||||
conf.autostart_path = fetch_opt_first(sec, "", "autostart_path").str;
|
conf.autostart_path = fetch_opt_first(sec, "", "autostart_path").str;
|
||||||
conf.autostart_command = fetch_opt_first(sec, "", "autostart_command").str;
|
conf.autostart_command = fetch_opt_first(sec, "", "autostart_command").str;
|
||||||
pad = fetch_opt_first(sec, "12", "pad").num;
|
pad = fetch_opt_first(sec, "12", "pad").num;
|
||||||
@ -203,12 +201,6 @@ conf_misc_section(void)
|
|||||||
|
|
||||||
conf.pad = pad;
|
conf.pad = pad;
|
||||||
|
|
||||||
if(conf.status_timing < 0)
|
|
||||||
{
|
|
||||||
warnx("configuration : status_timing value (%d) incorrect.", conf.status_timing);
|
|
||||||
conf.status_timing = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -281,10 +281,6 @@ clientmessageevent(XEvent *e)
|
|||||||
screen_get_sel();
|
screen_get_sel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manage _WMFS_UPDATE_STATUS */
|
|
||||||
if(mess_t == wmfs_update_status && estatus)
|
|
||||||
spawn(conf.status_path);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -95,7 +95,6 @@ ewmh_init_hints(void)
|
|||||||
/* WMFS hints */
|
/* WMFS hints */
|
||||||
net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
|
net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
|
||||||
net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS");
|
net_atom[wmfs_update_hints] = ATOM("_WMFS_UPDATE_HINTS");
|
||||||
net_atom[wmfs_update_status] = ATOM("_WMFS_UPDATE_STATUS");
|
|
||||||
net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN");
|
net_atom[wmfs_set_screen] = ATOM("_WMFS_SET_SCREEN");
|
||||||
net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
|
net_atom[wmfs_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
|
||||||
net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");
|
net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");
|
||||||
|
|||||||
38
src/init.c
38
src/init.c
@ -196,43 +196,6 @@ init_root(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Init statustext shell script
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
init_status(void)
|
|
||||||
{
|
|
||||||
struct stat st;
|
|
||||||
char *home;
|
|
||||||
|
|
||||||
conf.status_pid = -1;
|
|
||||||
estatus = False;
|
|
||||||
|
|
||||||
if(!conf.status_path)
|
|
||||||
{
|
|
||||||
if(!(home = getenv("HOME")))
|
|
||||||
{
|
|
||||||
warnx("HOME not set, can't launch status.sh");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf.status_path = zmalloc(strlen(home) + strlen(DEF_STATUS) + 2);
|
|
||||||
sprintf(conf.status_path, "%s/"DEF_STATUS, home);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(patht(conf.status_path), &st) == -1)
|
|
||||||
{
|
|
||||||
warn("%s", patht(conf.status_path));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(st.st_size && st.st_mode & S_IXUSR)
|
|
||||||
estatus = True;
|
|
||||||
else
|
|
||||||
warnx("status file specified in configuratin (status_path) or present in wmfs directory can't be executed, try 'chmod +x %s'.", patht(conf.status_path));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Init WMFS
|
/** Init WMFS
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -250,7 +213,6 @@ init(void)
|
|||||||
event_make_array();
|
event_make_array();
|
||||||
infobar_init();
|
infobar_init();
|
||||||
systray_acquire();
|
systray_acquire();
|
||||||
init_status();
|
|
||||||
ewmh_update_current_tag_prop();
|
ewmh_update_current_tag_prop();
|
||||||
grabkeys();
|
grabkeys();
|
||||||
|
|
||||||
|
|||||||
@ -158,7 +158,6 @@ enum
|
|||||||
/* WMFS HINTS */
|
/* WMFS HINTS */
|
||||||
wmfs_running,
|
wmfs_running,
|
||||||
wmfs_update_hints,
|
wmfs_update_hints,
|
||||||
wmfs_update_status,
|
|
||||||
wmfs_current_tag,
|
wmfs_current_tag,
|
||||||
wmfs_current_screen,
|
wmfs_current_screen,
|
||||||
wmfs_current_layout,
|
wmfs_current_layout,
|
||||||
@ -413,9 +412,6 @@ typedef struct
|
|||||||
bool tagnamecount;
|
bool tagnamecount;
|
||||||
Tag default_tag;
|
Tag default_tag;
|
||||||
uint pad;
|
uint pad;
|
||||||
int status_timing;
|
|
||||||
char *status_path;
|
|
||||||
pid_t status_pid;
|
|
||||||
char *autostart_path;
|
char *autostart_path;
|
||||||
char *autostart_command;
|
char *autostart_command;
|
||||||
struct
|
struct
|
||||||
|
|||||||
59
src/wmfs.c
59
src/wmfs.c
@ -143,77 +143,18 @@ quit(void)
|
|||||||
|
|
||||||
free(event_handle);
|
free(event_handle);
|
||||||
|
|
||||||
/* kill status script */
|
|
||||||
if (conf.status_pid != (pid_t)-1)
|
|
||||||
kill(conf.status_pid, SIGTERM);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
wait_childs_and_status(void)
|
|
||||||
{
|
|
||||||
int pid;
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mtx);
|
|
||||||
if (sig_chld) {
|
|
||||||
while ((pid = waitpid(-1, NULL, WNOHANG)) > 0)
|
|
||||||
if (pid == conf.status_pid)
|
|
||||||
conf.status_pid = -1;
|
|
||||||
sig_chld = False;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void *
|
|
||||||
thread_status(void *arg)
|
|
||||||
{
|
|
||||||
(void)arg;
|
|
||||||
int left = conf.status_timing;
|
|
||||||
|
|
||||||
pthread_detach(pthread_self());
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
wait_childs_and_status();
|
|
||||||
|
|
||||||
pthread_mutex_lock(&mtx);
|
|
||||||
if (conf.status_pid == -1)
|
|
||||||
conf.status_pid = spawn(conf.status_path);
|
|
||||||
pthread_mutex_unlock(&mtx);
|
|
||||||
|
|
||||||
while ((left = sleep(left)) > 0);
|
|
||||||
left = conf.status_timing;
|
|
||||||
|
|
||||||
} while (!exiting);
|
|
||||||
|
|
||||||
pthread_exit(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** WMFS main loop.
|
/** WMFS main loop.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mainloop(void)
|
mainloop(void)
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
pthread_t th_status;
|
|
||||||
|
|
||||||
if(estatus && !conf.status_timing)
|
|
||||||
conf.status_pid = spawn(conf.status_path);
|
|
||||||
else if(estatus && pthread_create(&th_status, NULL, thread_status, NULL) != 0)
|
|
||||||
{
|
|
||||||
warnx("pthread_create");
|
|
||||||
estatus = False;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!exiting && !XNextEvent(dpy, &ev))
|
while(!exiting && !XNextEvent(dpy, &ev))
|
||||||
{
|
|
||||||
HANDLE_EVENT(&ev);
|
HANDLE_EVENT(&ev);
|
||||||
wait_childs_and_status();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(estatus)
|
|
||||||
pthread_join(th_status, NULL);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -442,7 +442,6 @@ int selscreen;
|
|||||||
int prevselscreen;
|
int prevselscreen;
|
||||||
Conf conf;
|
Conf conf;
|
||||||
Key *keys;
|
Key *keys;
|
||||||
bool estatus;
|
|
||||||
Geo *sgeo;
|
Geo *sgeo;
|
||||||
Geo *spgeo;
|
Geo *spgeo;
|
||||||
Cursor cursor[CurLast];
|
Cursor cursor[CurLast];
|
||||||
|
|||||||
2
wmfsrc
2
wmfsrc
@ -18,8 +18,6 @@
|
|||||||
# true -- default, set focus
|
# true -- default, set focus
|
||||||
# false -- click go to client; including dockapps
|
# false -- click go to client; including dockapps
|
||||||
focus_pointer_click = true
|
focus_pointer_click = true
|
||||||
status_timing = 1 #seconds
|
|
||||||
# status_path = "~/.config/wmfs/status.sh"
|
|
||||||
[/misc]
|
[/misc]
|
||||||
|
|
||||||
[bar]
|
[bar]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user