diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-09-30 14:17:30 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 11:57:56 +0200 |
commit | b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd (patch) | |
tree | f98a137122c20ffb08a21150dabb0e6b6f8856b2 /src/util.vala | |
parent | cab9f6acc55a464bbc10638d7cb186ab41c918d6 (diff) | |
download | arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.tar.gz arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.tar.bz2 arctica-greeter-b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd.zip |
Move greeter_set_env to AGUtils.
This may be a helpful method we might need in the future in a more global
context.
Diffstat (limited to 'src/util.vala')
-rw-r--r-- | src/util.vala | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/util.vala b/src/util.vala index 6b82f50..a9116f7 100644 --- a/src/util.vala +++ b/src/util.vala @@ -26,3 +26,33 @@ [CCode(cname = "GTK_IS_CONTAINER", cheader_filename="gtk/gtk.h", simple_generics = true, has_target = false)] static extern bool gtk_is_container<T> (T widget); #endif + +namespace AGUtils { + public void greeter_set_env (string key, string val) + { + GLib.Environment.set_variable (key, val, true); + + /* And also set it in the DBus activation environment so that any + * indicator services pick it up. */ + try + { + var proxy = new GLib.DBusProxy.for_bus_sync (GLib.BusType.SESSION, + GLib.DBusProxyFlags.NONE, null, + "org.freedesktop.DBus", + "/org/freedesktop/DBus", + "org.freedesktop.DBus", + null); + + var builder = new GLib.VariantBuilder (GLib.VariantType.ARRAY); + builder.add ("{ss}", key, val); + + debug ("Updating DBus activation environment, updating '%s' to '%s'", key, val); + proxy.call_sync ("UpdateActivationEnvironment", new GLib.Variant ("(a{ss})", builder), GLib.DBusCallFlags.NONE, -1, null); + } + catch (Error e) + { + warning ("Could not set environment variable '%s' to '%s', error was: '%s'", key, val, e.message); + return; + } + } +} |