diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-12 23:50:45 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-12 23:50:45 +0200 |
commit | 7b0bf0688b3c4504198e2bddc6f6c5b22b2f97dc (patch) | |
tree | b5c1eca6bd4d4da427b5f382df6799afe6fb8614 /src | |
parent | f4e287ab8949b95148328ba0ddd10c69ba63dfba (diff) | |
download | arctica-greeter-7b0bf0688b3c4504198e2bddc6f6c5b22b2f97dc.tar.gz arctica-greeter-7b0bf0688b3c4504198e2bddc6f6c5b22b2f97dc.tar.bz2 arctica-greeter-7b0bf0688b3c4504198e2bddc6f6c5b22b2f97dc.zip |
Wait with Ayatana Indicators startup until D-Bus mimick services have come up.
Diffstat (limited to 'src')
-rw-r--r-- | src/arctica-greeter.vala | 188 | ||||
-rw-r--r-- | src/settings-daemon.vala | 9 |
2 files changed, 108 insertions, 89 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index a2aa59e..121d643 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -54,6 +54,8 @@ public class ArcticaGreeter : Object public signal void xsettings_ready (); public signal void greeter_ready (); + public List<Pid> indicator_service_pids; + construct { Bus.own_name (BusType.SESSION, "org.ayatana.greeter", BusNameOwnerFlags.NONE, onBusAcquired); @@ -932,6 +934,102 @@ public class ArcticaGreeter : Object return ret; } + public void start_indicators () + { + var indicator_list = AGSettings.get_strv(AGSettings.KEY_INDICATORS); + + var update_indicator_list = false; + for (var i = 0; i < indicator_list.length; i++) + { + if (indicator_list[i] == "ug-keyboard") + { + indicator_list[i] = "org.ayatana.indicator.keyboard"; + update_indicator_list = true; + } + } + + if (update_indicator_list) + AGSettings.set_strv(AGSettings.KEY_INDICATORS, indicator_list); + + if (!test_mode) + { + var indicator_service = ""; + foreach (unowned string indicator in indicator_list) + { + Pid indicator_service_pid = 0; + + if ("ug-" in indicator && ! ("." in indicator)) + continue; + + if ("org.ayatana.indicator." in indicator) + indicator_service = "ayatana-indicator-%s".printf(indicator.split_set(".")[3]); + else if ("ayatana-" in indicator) + indicator_service = "ayatana-indicator-%s".printf(indicator.split_set("-")[1]); + else + indicator_service = indicator; + + try { + /* Start the indicator service */ + string[] argv = null; + + /* FIXME: This path is rather hard-coded here. + * If it pops up, we need to handle this in + * some path detection fashion similar to + * how we find at-spi-bus-launcher on the file + * system. + */ + if (FileUtils.test ("/usr/lib/%s/%s-service".printf(indicator_service, indicator_service), FileTest.EXISTS)) + Shell.parse_argv ("/usr/lib/%s/%s-service".printf(indicator_service, indicator_service), out argv); + else if (FileUtils.test ("/usr/libexec/%s/%s-service".printf(indicator_service, indicator_service), FileTest.EXISTS)) + Shell.parse_argv ("/usr/libexec/%s/%s-service".printf(indicator_service, indicator_service), out argv); + if (argv != null) + { + Process.spawn_async (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + out indicator_service_pid); + indicator_service_pids.append(indicator_service_pid); + debug ("Successfully started Ayatana Indicator Service '%s' [%d]", indicator_service, indicator_service_pid); + } + else + { + warning ("Could not find indicator service executable for Indicator Service '%s'", indicator_service); + } + } + catch (Error e) + { + warning ("Error starting Indicator Service '%s': %s", indicator_service, e.message); + } + + } + } + } + + public void stop_indicators () + { + foreach (unowned Pid indicator_service_pid in indicator_service_pids) + { + if (indicator_service_pid != 0) + { +#if VALA_0_40 + Posix.kill (indicator_service_pid, Posix.Signal.TERM); +#else + Posix.kill (indicator_service_pid, Posix.SIGTERM); +#endif + + int status; + Posix.waitpid (indicator_service_pid, out status, 0); + if (Process.if_exited (status)) + debug ("Indicator Service process [%d] exited with return value %d", indicator_service_pid, Process.exit_status (status)); + else + debug ("Indicator Service process [%d] terminated with signal %d", indicator_service_pid, Process.term_sig (status)); + indicator_service_pid = 0; + } + } + } + public static int main (string[] args) { /* Protect memory from being paged to disk, as we deal with passwords @@ -1222,23 +1320,6 @@ public class ArcticaGreeter : Object Pid nmapplet_pid = 0; - var indicator_list = AGSettings.get_strv(AGSettings.KEY_INDICATORS); - - var update_indicator_list = false; - for (var i = 0; i < indicator_list.length; i++) - { - if (indicator_list[i] == "ug-keyboard") - { - indicator_list[i] = "org.ayatana.indicator.keyboard"; - update_indicator_list = true; - } - } - - if (update_indicator_list) - AGSettings.set_strv(AGSettings.KEY_INDICATORS, indicator_list); - - var launched_indicator_service_pids = new List<Pid>(); - if (!do_test_mode) { @@ -1249,58 +1330,6 @@ public class ArcticaGreeter : Object greeter.show (); }); - var indicator_service = ""; - foreach (unowned string indicator in indicator_list) - { - Pid indicator_service_pid = 0; - - if ("ug-" in indicator && ! ("." in indicator)) - continue; - - if ("org.ayatana.indicator." in indicator) - indicator_service = "ayatana-indicator-%s".printf(indicator.split_set(".")[3]); - else if ("ayatana-" in indicator) - indicator_service = "ayatana-indicator-%s".printf(indicator.split_set("-")[1]); - else - indicator_service = indicator; - - try { - /* Start the indicator service */ - string[] argv = null; - - /* FIXME: This path is rather hard-coded here. - * If it pops up, we need to handle this in - * some path detection fashion similar to - * how we find at-spi-bus-launcher on the file - * system. - */ - if (FileUtils.test ("/usr/lib/%s/%s-service".printf(indicator_service, indicator_service), FileTest.EXISTS)) - Shell.parse_argv ("/usr/lib/%s/%s-service".printf(indicator_service, indicator_service), out argv); - else if (FileUtils.test ("/usr/libexec/%s/%s-service".printf(indicator_service, indicator_service), FileTest.EXISTS)) - Shell.parse_argv ("/usr/libexec/%s/%s-service".printf(indicator_service, indicator_service), out argv); - if (argv != null) - { - Process.spawn_async (null, - argv, - null, - SpawnFlags.SEARCH_PATH, - null, - out indicator_service_pid); - launched_indicator_service_pids.append(indicator_service_pid); - debug ("Successfully started Ayatana Indicator Service '%s' [%d]", indicator_service, indicator_service_pid); - } - else - { - warning ("Could not find indicator service executable for Indicator Service '%s'", indicator_service); - } - } - catch (Error e) - { - warning ("Error starting Indicator Service '%s': %s", indicator_service, e.message); - } - - } - try { string[] argv; @@ -1338,26 +1367,7 @@ public class ArcticaGreeter : Object if (!do_test_mode) { - foreach (unowned Pid indicator_service_pid in launched_indicator_service_pids) - { - if (indicator_service_pid != 0) - { -#if VALA_0_40 - Posix.kill (indicator_service_pid, Posix.Signal.TERM); -#else - Posix.kill (indicator_service_pid, Posix.SIGTERM); -#endif - - int status; - Posix.waitpid (indicator_service_pid, out status, 0); - if (Process.if_exited (status)) - debug ("Indicator Service process [%d] exited with return value %d", indicator_service_pid, Process.exit_status (status)); - else - debug ("Indicator Service process [%d] terminated with signal %d", indicator_service_pid, Process.term_sig (status)); - indicator_service_pid = 0; - } - } - + greeter.stop_indicators(); greeter.settings_daemon.stop(); if (nmapplet_pid != 0) diff --git a/src/settings-daemon.vala b/src/settings-daemon.vala index d8766d5..5fa9117 100644 --- a/src/settings-daemon.vala +++ b/src/settings-daemon.vala @@ -205,6 +205,15 @@ public class SettingsDaemon : Object { debug ("Could not start %s: %s", Config.SD_BINARY, e.message); } + + /* Start Ayatana Indicators... + * The indicator start has been moved here, because the session + * indicator requires org.gnome.ScreenSaver to have been setup + * accurately (which is happening before the settings-daemon start). + */ + debug ("Launching Ayatana Indicators..."); + var greeter = new ArcticaGreeter(); + greeter.start_indicators (); } private void stop_settings_daemon () |