diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-17 13:25:31 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2024-06-18 08:48:10 +0200 |
commit | 30e18f5dcc772bd6cbc4c7524a0bdac17dfe57da (patch) | |
tree | 313880ad86b7fe856bfd8225d51cfb50075d57db | |
parent | 7e692b9d601d975eadb6c7814b983743ad26c9be (diff) | |
download | arctica-greeter-30e18f5dcc772bd6cbc4c7524a0bdac17dfe57da.tar.gz arctica-greeter-30e18f5dcc772bd6cbc4c7524a0bdac17dfe57da.tar.bz2 arctica-greeter-30e18f5dcc772bd6cbc4c7524a0bdac17dfe57da.zip |
Support openSUSE style of marking the default (X11) session.
-rw-r--r-- | src/arctica-greeter.vala | 85 | ||||
-rw-r--r-- | src/session-list.vala | 68 |
2 files changed, 113 insertions, 40 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 684c368..78c34b5 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -254,58 +254,75 @@ public class ArcticaGreeter : Object public string? get_default_session () { - var sessions = new List<string> (); + var available_sessions = new List<string> (); var hide_default_xsession = AGSettings.get_boolean (AGSettings.KEY_HIDE_DEFAULT_XSESSION); + + /* Debian/Ubuntu style of defining the default xsession. + */ if (!hide_default_xsession) { - sessions.append ("lightdm-xsession"); + var default_session_path_suse = Path.build_filename ("/usr/share/xsessions/default.desktop", null); + var default_session_path_deb = Path.build_filename ("/usr/share/xsessions/lightdm-xsession.desktop", null); + if (FileUtils.test (default_session_path_suse, FileTest.EXISTS)) { + /* openSUSE/SLED style of defining the default xsession. + */ + available_sessions.append ("default"); + } + else if (FileUtils.test (default_session_path_deb, FileTest.EXISTS)) { + /* Debian/Ubuntu style of defining the default xsession. + */ + available_sessions.append ("lightdm-xsession"); + } } var preferred_sessions = AGSettings.get_strv (AGSettings.KEY_PREFERRED_SESSIONS); + if (preferred_sessions.length > 0) { + foreach (var preferred_session in preferred_sessions) { + available_sessions.append (preferred_session); + } - foreach (var preferred_session in preferred_sessions) { - sessions.append (preferred_session); - } - - var excluded_sessions = AGSettings.get_strv (AGSettings.KEY_EXCLUDED_SESSIONS); - var includeonly_sessions = AGSettings.get_strv (AGSettings.KEY_INCLUDEONLY_SESSIONS); + var excluded_sessions = AGSettings.get_strv (AGSettings.KEY_EXCLUDED_SESSIONS); + var includeonly_sessions = AGSettings.get_strv (AGSettings.KEY_INCLUDEONLY_SESSIONS); - if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_WAYLAND_SESSIONS)) { - foreach (string session in sessions) { - if (includeonly_sessions.length > 0) { - if (!(session in includeonly_sessions)) { + if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_WAYLAND_SESSIONS)) { + foreach (string session in available_sessions) { + if (includeonly_sessions.length > 0) { + if (!(session in includeonly_sessions)) { + continue; + } + } + else if (session in excluded_sessions) { continue; } - } - else if (session in excluded_sessions) { - continue; - } - var path = Path.build_filename ("/usr/share/wayland-sessions/", session.concat(".desktop"), null); - if (FileUtils.test (path, FileTest.EXISTS)) { - debug ("Using %s as default (Wayland) session.", session); - return session; + var path = Path.build_filename ("/usr/share/wayland-sessions/", session.concat(".desktop"), null); + if (FileUtils.test (path, FileTest.EXISTS)) { + debug ("Using %s as default (Wayland) session.", session); + return session; + } } } - } - if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_X11_SESSIONS)) { - foreach (string session in sessions) { - if (includeonly_sessions.length > 0) { - if (!(session in includeonly_sessions)) { + if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_X11_SESSIONS)) { + foreach (string session in available_sessions) { + if (includeonly_sessions.length > 0) { + if (!(session in includeonly_sessions)) { + continue; + } + } + else if (session in excluded_sessions) { continue; } - } - else if (session in excluded_sessions) { - continue; - } - var path = Path.build_filename ("/usr/share/xsessions/", session.concat(".desktop"), null); - if (FileUtils.test (path, FileTest.EXISTS)) { - debug ("Using %s as default (X11) session.", session); - return session; + var path = Path.build_filename ("/usr/share/xsessions/", session.concat(".desktop"), null); + if (FileUtils.test (path, FileTest.EXISTS)) { + debug ("Using %s as default (X11) session.", session); + return session; + } } } + + warning ("Could not find a default session. Falling back to LightDM's system default."); } - warning ("Could not find a default session. Falling back to LightDM's system default."); + warning ("Using default session '%s' as configured as LightDM's system default.", greeter.default_session_hint); return greeter.default_session_hint; } diff --git a/src/session-list.vala b/src/session-list.vala index eef234b..3d92ce7 100644 --- a/src/session-list.vala +++ b/src/session-list.vala @@ -47,14 +47,50 @@ public class SessionPrompt : PromptBox } else { - var sessions = LightDM.get_sessions().copy(); - sessions.sort_with_data((a, b) => GLib.strcmp (a.name.casefold().collate_key(), b.name.casefold().collate_key())); - foreach (var session in sessions) + /* Pick the selected session (if any) and add it as first item. + */ + var dm_sessions = LightDM.get_sessions().copy(); + foreach (var dm_session in dm_sessions) { + if (dm_session.key == session) { + debug ("Adding session %s (%s) as first entry", dm_session.key, dm_session.name); + box.add_item (dm_session.key, dm_session.name, SessionList.get_badge (dm_session.key)); + break; + } + } + /* Pick the default session (if different from selected session) and add it as next item. + */ + if (session != default_session) { + foreach (var dm_session in dm_sessions) + { + if (dm_session.key == default_session) { + debug ("Adding session %s (%s) as second entry", dm_session.key, dm_session.name); + box.add_item (dm_session.key, dm_session.name, SessionList.get_badge (dm_session.key)); + break; + } + } + } + + dm_sessions.sort_with_data((a, b) => GLib.strcmp (a.name.casefold().collate_key(), b.name.casefold().collate_key())); + foreach (var dm_session in dm_sessions) + { + /* Skip the selected session, we already have added that as first time. + */ + if (dm_session.key == session) { + continue; + } + + /* Skip the default session, we already have added that as first or second item + (depending on whether there was a selected session). + */ + if (dm_session.key == default_session) { + continue; + } + /* Apply hide x11/wayland filter */ - if (greeter.validate_session(session.key, false) != null) { - debug ("Adding session %s (%s)", session.key, session.name); - box.add_item (session.key, session.name, SessionList.get_badge (session.key)); + if (greeter.validate_session(dm_session.key, false) != null) { + debug ("Adding session %s (%s)", dm_session.key, dm_session.name); + box.add_item (dm_session.key, dm_session.name, SessionList.get_badge (dm_session.key)); } } } @@ -193,6 +229,26 @@ public class SessionList : GreeterList private static HashTable<string, Gdk.Pixbuf> badges; /* cache of badges */ public static Gdk.Pixbuf? get_badge (string session) { + if (session == "default") + { + var sessions = LightDM.get_sessions().copy(); + foreach (var find_session in sessions) + { + if (find_session.key == "default") + { + foreach (var real_session in sessions) + { + if (real_session.name == find_session.name) + { + session = real_session.key; + break; + } + } + break; + } + } + } + var name = get_badge_name_from_alias_list (session); if (name == null) |