diff options
author | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-05-22 18:34:03 +0200 |
---|---|---|
committer | Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> | 2014-05-22 18:34:03 +0200 |
commit | 3b54139298e19340051ec0978fa125acaa58120a (patch) | |
tree | fc7099207e7be94c28bbce69c51f625f9c639227 | |
parent | 7043d02468575d51363b3aa6d80ee06444af1d6e (diff) | |
download | weston-common-3b54139298e19340051ec0978fa125acaa58120a.tar.gz weston-common-3b54139298e19340051ec0978fa125acaa58120a.tar.bz2 weston-common-3b54139298e19340051ec0978fa125acaa58120a.zip |
tz-launcher: support signal to reload launchers at runtime
When sent a SIGUSR1 signal ("$ kill -10 $PID"), tz-launcher will
now re-read the content of the files/folders which have been passed
to it, and display the corresponding new launchers.
Change-Id: I29d7a5f2d9d63132189da50e08dd1860af849bb6
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
-rw-r--r-- | tz-launcher/tz-launcher-wl.c | 10 | ||||
-rw-r--r-- | tz-launcher/tz-launcher.c | 47 |
2 files changed, 44 insertions, 13 deletions
diff --git a/tz-launcher/tz-launcher-wl.c b/tz-launcher/tz-launcher-wl.c index c990423..5c32ae5 100644 --- a/tz-launcher/tz-launcher-wl.c +++ b/tz-launcher/tz-launcher-wl.c @@ -32,6 +32,7 @@ struct launcher { gboolean terminal; }; +struct display *display; struct main_window *main_window; @@ -452,9 +453,16 @@ main_window_destroy () } void +tz_launcher_wl_reload (int desktopfiles, gchar ***desktoptable) +{ + main_window_destroy (); + main_window_create (display, desktopfiles, desktoptable); +} + +void tz_launcher_wl_run (int desktopfiles, gchar ***desktoptable) { - struct display *display = NULL; + display = NULL; int retries = 0; while (!display) { diff --git a/tz-launcher/tz-launcher.c b/tz-launcher/tz-launcher.c index f57618b..7a50fc2 100644 --- a/tz-launcher/tz-launcher.c +++ b/tz-launcher/tz-launcher.c @@ -8,6 +8,9 @@ int desktopfiles; gchar **desktoptable[MAX_DESKTOPFILES]; +int global_argc; +char **global_argv; + gboolean file_is_parsable (GFile *file) @@ -200,21 +203,12 @@ tz_launcher_parse_config_file (GFile *file) } -int -main (int argc, char *argv[]) +void +parse_args (int argc, char **argv) { - if (argc < 2) { - g_print ("Usage : tz-launcher <file1>.desktop <file2>.desktop <directory>...\n" - " or\n" - " tz-launcher -c <list-of-.desktop-files>.conf\n"); - return 0; - } - - desktopfiles = 0; - g_type_init (); - int i; + desktopfiles = 0; GFile *desktopfile; for (i = 1; i < argc ; i++) { @@ -257,7 +251,36 @@ main (int argc, char *argv[]) if (desktopfiles == MAX_DESKTOPFILES) break; } +} + +static void +sigreload_handler (int s) +{ + parse_args (global_argc, global_argv); + + if (desktopfiles > 0) + tz_launcher_wl_reload (desktopfiles, desktoptable); +} + +int +main (int argc, char **argv) +{ + if (argc < 2) { + g_print ("Usage : tz-launcher <file1>.desktop <file2>.desktop <directory>...\n" + " or\n" + " tz-launcher -c <list-of-.desktop-files>.conf\n"); + return 0; + } + + g_type_init (); + + + signal (SIGUSR1, sigreload_handler); + global_argc = argc; + global_argv = argv; + + parse_args (argc, argv); if (desktopfiles > 0) tz_launcher_wl_run (desktopfiles, desktoptable); |