Status: Remove status management (status_path, status_timing, threading), use loop in status script now (see scripts/status.sh)

This commit is contained in:
Martin Duquesnoy 2011-07-28 00:08:43 +02:00
parent 7bfba91a92
commit 4e33bc9bf7
9 changed files with 1 additions and 118 deletions

View File

@ -8,4 +8,4 @@ statustext()
wmfs -s "`date`"
}
statustext
while true; do statustext; sleep 10; done

View File

@ -183,8 +183,6 @@ conf_misc_section(void)
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_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_command = fetch_opt_first(sec, "", "autostart_command").str;
pad = fetch_opt_first(sec, "12", "pad").num;
@ -203,12 +201,6 @@ conf_misc_section(void)
conf.pad = pad;
if(conf.status_timing < 0)
{
warnx("configuration : status_timing value (%d) incorrect.", conf.status_timing);
conf.status_timing = 1;
}
return;
}

View File

@ -281,10 +281,6 @@ clientmessageevent(XEvent *e)
screen_get_sel();
}
/* Manage _WMFS_UPDATE_STATUS */
if(mess_t == wmfs_update_status && estatus)
spawn(conf.status_path);
return;
}

View File

@ -95,7 +95,6 @@ ewmh_init_hints(void)
/* WMFS hints */
net_atom[wmfs_running] = ATOM("_WMFS_RUNNING");
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_screen_count] = ATOM("_WMFS_SCREEN_COUNT");
net_atom[wmfs_current_tag] = ATOM("_WMFS_CURRENT_TAG");

View File

@ -196,43 +196,6 @@ init_root(void)
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
*/
void
@ -250,7 +213,6 @@ init(void)
event_make_array();
infobar_init();
systray_acquire();
init_status();
ewmh_update_current_tag_prop();
grabkeys();

View File

@ -158,7 +158,6 @@ enum
/* WMFS HINTS */
wmfs_running,
wmfs_update_hints,
wmfs_update_status,
wmfs_current_tag,
wmfs_current_screen,
wmfs_current_layout,
@ -413,9 +412,6 @@ typedef struct
bool tagnamecount;
Tag default_tag;
uint pad;
int status_timing;
char *status_path;
pid_t status_pid;
char *autostart_path;
char *autostart_command;
struct

View File

@ -143,77 +143,18 @@ quit(void)
free(event_handle);
/* kill status script */
if (conf.status_pid != (pid_t)-1)
kill(conf.status_pid, SIGTERM);
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.
*/
static void
mainloop(void)
{
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))
{
HANDLE_EVENT(&ev);
wait_childs_and_status();
}
if(estatus)
pthread_join(th_status, NULL);
return;
}

View File

@ -442,7 +442,6 @@ int selscreen;
int prevselscreen;
Conf conf;
Key *keys;
bool estatus;
Geo *sgeo;
Geo *spgeo;
Cursor cursor[CurLast];

2
wmfsrc
View File

@ -18,8 +18,6 @@
# true -- default, set focus
# false -- click go to client; including dockapps
focus_pointer_click = true
status_timing = 1 #seconds
# status_path = "~/.config/wmfs/status.sh"
[/misc]
[bar]