diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-11-18 22:00:57 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-11-18 22:00:57 +0100 |
commit | 6e6190e42e5bd4b65b29ee4672f0a37a035e50c8 (patch) | |
tree | 9456df9c90d3ada82ca1b12efc382b0a1ab8a4b5 | |
parent | 7f203af2c4e1861eb05f0101e079a6d208f9e82f (diff) | |
download | arctica-greeter-6e6190e42e5bd4b65b29ee4672f0a37a035e50c8.tar.gz arctica-greeter-6e6190e42e5bd4b65b29ee4672f0a37a035e50c8.tar.bz2 arctica-greeter-6e6190e42e5bd4b65b29ee4672f0a37a035e50c8.zip |
src/arctica-greeter.vala: Support (configurably) loading the GeoClue-2.0 agent.
-rw-r--r-- | data/org.ArcticaProject.arctica-greeter.gschema.xml | 4 | ||||
-rw-r--r-- | src/arctica-greeter.vala | 45 | ||||
-rw-r--r-- | src/settings.vala | 1 |
3 files changed, 50 insertions, 0 deletions
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 @@ <default>[]</default> <summary>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.</summary> </key> + <key name="geoclue-agent" type="b"> + <default>true</default> + <summary>Whether to enable the GeoClue-2.0 agent (enhances ayatana-indicator-display).</summary> + </key> </schema> </schemalist> 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) { |