summaryrefslogtreecommitdiff
path: root/gnome-base/gdm/files/gdm-set-session
diff options
context:
space:
mode:
Diffstat (limited to 'gnome-base/gdm/files/gdm-set-session')
-rwxr-xr-xgnome-base/gdm/files/gdm-set-session52
1 files changed, 52 insertions, 0 deletions
diff --git a/gnome-base/gdm/files/gdm-set-session b/gnome-base/gdm/files/gdm-set-session
new file mode 100755
index 00000000..491b9a67
--- /dev/null
+++ b/gnome-base/gdm/files/gdm-set-session
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+"""Simple script that updates the default session in AccountServices"""
+
+import sys
+import time
+
+from gi.repository import GLib as glib
+
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+
+ACCOUNTS_DBUS_NAME = "org.freedesktop.Accounts"
+ACCOUNTS_DBUS_PATH = "/org/freedesktop/Accounts"
+ACCOUNTS_USER_DBUS_NAME = "org.freedesktop.Accounts.User"
+
+if __name__ == "__main__":
+
+ try:
+ username = sys.argv[1]
+ session = sys.argv[2]
+ except IndexError:
+ sys.stderr.write("%s <username> <default session>\n")
+ raise SystemExit(1)
+
+ dbus_loop = DBusGMainLoop(set_as_default = True)
+ loop = glib.MainLoop()
+ glib.threads_init()
+
+ def setup():
+ try:
+ system_bus = dbus.SystemBus(mainloop=dbus_loop)
+ dbus_object = system_bus.get_object(
+ ACCOUNTS_DBUS_NAME, ACCOUNTS_DBUS_PATH)
+
+ iface = dbus.Interface(
+ dbus_object, dbus_interface=ACCOUNTS_DBUS_NAME)
+
+ user_path = iface.FindUserByName(username)
+
+ dbus_object = system_bus.get_object(
+ ACCOUNTS_DBUS_NAME, user_path)
+
+ iface_usr = dbus.Interface(
+ dbus_object, dbus_interface=ACCOUNTS_USER_DBUS_NAME)
+
+ iface_usr.SetXSession(session)
+
+ finally:
+ loop.quit()
+
+ glib.timeout_add(0, setup)
+ loop.run()