From 6e6190e42e5bd4b65b29ee4672f0a37a035e50c8 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Sat, 18 Nov 2023 22:00:57 +0100 Subject: src/arctica-greeter.vala: Support (configurably) loading the GeoClue-2.0 agent. --- .../org.ArcticaProject.arctica-greeter.gschema.xml | 4 ++ src/arctica-greeter.vala | 45 ++++++++++++++++++++++ src/settings.vala | 1 + 3 files changed, 50 insertions(+) diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index 23353b2..02a4978 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -247,5 +247,9 @@ [] Unordered list of excluded desktop sessions (if non-empty, listed sessions types will not be offered by the greeter). Only used if includeonly-sessions is empty. + + true + Whether to enable the GeoClue-2.0 agent (enhances ayatana-indicator-display). + diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 1f1f6d3..7f1ddb2 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -1086,6 +1086,35 @@ public class ArcticaGreeter : Object } } + Pid geoclueagent_pid = 0; + if (AGSettings.get_boolean (AGSettings.KEY_GEOCLUE_AGENT) && (!do_test_mode)) + { + + try + { + string[] argv = null; + + if (FileUtils.test ("/usr/lib/geoclue-2.0/demos/agent", FileTest.EXISTS)) { + Shell.parse_argv ("/usr/lib/geoclue-2.0/demos/agent", out argv); + } + else if (FileUtils.test ("/usr/libexec/geoclue-2.0/demos/agent", FileTest.EXISTS)) { + Shell.parse_argv ("/usr/libexec/geoclue-2.0/demos/agent", out argv); + } + if (argv != null) + Process.spawn_async (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + out geoclueagent_pid); + debug ("Launched GeoClue-2.0 agent. PID: %d", geoclueagent_pid); + } + catch (Error e) + { + warning ("Error starting the GeoClue-2.0 agent: %s", e.message); + } + } + /* Enable touchpad tap-to-click */ enable_tap_to_click (); @@ -1337,6 +1366,22 @@ public class ArcticaGreeter : Object debug ("AT-SPI terminated with signal %d", Process.term_sig (status)); atspi_pid = 0; } + + if (geoclueagent_pid != 0) + { +#if VALA_0_40 + Posix.kill (geoclueagent_pid, Posix.Signal.KILL); +#else + Posix.kill (geoclueagent_pid, Posix.SIGKILL); +#endif + int status; + Posix.waitpid (geoclueagent_pid, out status, 0); + if (Process.if_exited (status)) + debug ("GeoClue-2.0 agent exited with return value %d", Process.exit_status (status)); + else + debug ("GeoClue-2.0 agent terminated with signal %d", Process.term_sig (status)); + geoclueagent_pid = 0; + } } var screen = Gdk.Screen.get_default (); diff --git a/src/settings.vala b/src/settings.vala index e4386a6..74e6e40 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -82,6 +82,7 @@ public class AGSettings : Object public const string KEY_EXCLUDED_SESSIONS = "excluded-sessions"; public const string KEY_SHUTDOWN_DIALOG_TIMEOUT = "shutdown-dialog-timeout"; public const string KEY_PREFERRED_SESSIONS = "preferred-sessions"; + public const string KEY_GEOCLUE_AGENT = "geoclue-agent"; public static bool get_boolean (string key) { -- cgit v1.2.3