diff options
author | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 12:00:58 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2023-10-06 12:00:58 +0200 |
commit | adfa1f3b9b566127eb0dc5b1f96a8ddf1b4b5693 (patch) | |
tree | f98a137122c20ffb08a21150dabb0e6b6f8856b2 | |
parent | cab9f6acc55a464bbc10638d7cb186ab41c918d6 (diff) | |
parent | b96c7558d35f5106b4ea5fed6098e5e3e1f43ddd (diff) | |
download | arctica-greeter-adfa1f3b9b566127eb0dc5b1f96a8ddf1b4b5693.tar.gz arctica-greeter-adfa1f3b9b566127eb0dc5b1f96a8ddf1b4b5693.tar.bz2 arctica-greeter-adfa1f3b9b566127eb0dc5b1f96a8ddf1b4b5693.zip |
Merge branch 'sunweaver-mr/greeter-set-env'
Attributes GH PR #81: https://github.com/ArcticaProject/arctica-greeter/pull/81
-rw-r--r-- | src/menubar.vala | 37 | ||||
-rw-r--r-- | src/util.vala | 30 |
2 files changed, 35 insertions, 32 deletions
diff --git a/src/menubar.vala b/src/menubar.vala index b9772fa..6dd802b 100644 --- a/src/menubar.vala +++ b/src/menubar.vala @@ -288,33 +288,6 @@ public class MenuBar : Gtk.MenuBar nat = HEIGHT; } - private 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); - - proxy.call_sync ("UpdateActivationEnvironment", new GLib.Variant ("(a{ss})", builder), GLib.DBusCallFlags.NONE, -1, null); - } - catch (Error e) - { - warning ("Could not get set environment for indicators: %s", e.message); - return; - } - } - private Indicator.Object? load_indicator_file (string indicator_name) { string dir = Config.INDICATOR_FILE_DIR; @@ -386,20 +359,20 @@ public class MenuBar : Gtk.MenuBar private void setup_indicators () { /* Set indicators to run with reduced functionality */ - greeter_set_env ("INDICATOR_GREETER_MODE", "1"); + AGUtils.greeter_set_env ("INDICATOR_GREETER_MODE", "1"); /* Don't allow virtual file systems? */ - greeter_set_env ("GIO_USE_VFS", "local"); - greeter_set_env ("GVFS_DISABLE_FUSE", "1"); + AGUtils.greeter_set_env ("GIO_USE_VFS", "local"); + AGUtils.greeter_set_env ("GVFS_DISABLE_FUSE", "1"); /* Hint to have mate-settings-daemon run in greeter mode */ - greeter_set_env ("RUNNING_UNDER_GDM", "1"); + AGUtils.greeter_set_env ("RUNNING_UNDER_GDM", "1"); /* Let indicators know about our unique dbus name */ try { var conn = Bus.get_sync (BusType.SESSION); - greeter_set_env ("ARCTICA_GREETER_DBUS_NAME", conn.get_unique_name ()); + AGUtils.greeter_set_env ("ARCTICA_GREETER_DBUS_NAME", conn.get_unique_name ()); } catch (IOError e) { 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; + } + } +} |