diff options
author | Mihai Moldovan <ionic@ionic.de> | 2023-09-15 19:13:15 +0200 |
---|---|---|
committer | Mihai Moldovan <ionic@ionic.de> | 2023-09-15 19:13:15 +0200 |
commit | a10a482c08a6b0aa98206b07dc3c88efc474ecd7 (patch) | |
tree | 3b76f06fc4f856b35698a98b2b28b19d764fe093 | |
parent | 6c027e74fe2fdd1f750f6e2bdf9936cc0794de6e (diff) | |
parent | 8dfc61bf04dfc5e5977a5dd7aa2981c8fd609b3b (diff) | |
download | arctica-greeter-a10a482c08a6b0aa98206b07dc3c88efc474ecd7.tar.gz arctica-greeter-a10a482c08a6b0aa98206b07dc3c88efc474ecd7.tar.bz2 arctica-greeter-a10a482c08a6b0aa98206b07dc3c88efc474ecd7.zip |
Merge branch 'sunweaver-mr/hide-enforce-only-sessions'
Attributes GH PR #69: https://github.com/ArcticaProject/arctica-greeter/pull/69
-rw-r--r-- | data/org.ArcticaProject.arctica-greeter.gschema.xml | 8 | ||||
-rw-r--r-- | src/arctica-greeter.vala | 31 | ||||
-rw-r--r-- | src/settings.vala | 2 |
3 files changed, 41 insertions, 0 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index ddef373..db00737 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -219,5 +219,13 @@ <default>60</default> <summary>Time in seconds until the shutdown dialog forcefully selects the default action. Set to 0 to disable.</summary> </key> + <key name="includeonly-sessions" type="as"> + <default>[]</default> + <summary>Unordered list of include-only desktop sessions (if non-empty, only explicitly listed sessions types will be offered by the greeter). Takes precedence over the excluded-sessions list.</summary> + </key> + <key name="excluded-sessions" type="as"> + <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> </schema> </schemalist> diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index cacfdac..0aee212 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -254,8 +254,19 @@ public class ArcticaGreeter : Object sessions.append (preferred_session); } + 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)) { + 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); @@ -266,6 +277,14 @@ public class ArcticaGreeter : Object if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_X11_SESSIONS)) { foreach (string session in sessions) { + if (includeonly_sessions.length > 0) { + if (!(session in includeonly_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); @@ -283,6 +302,18 @@ public class ArcticaGreeter : Object /* Make sure the given session actually exists. Return it if it does. * otherwise, return the default session. */ + var excluded_sessions = AGSettings.get_strv (AGSettings.KEY_EXCLUDED_SESSIONS); + var includeonly_sessions = AGSettings.get_strv (AGSettings.KEY_INCLUDEONLY_SESSIONS); + + if (includeonly_sessions.length > 0) { + if (!(session in includeonly_sessions)) { + session = null; + } + } + else if (session in excluded_sessions) { + session = null; + } + if (session != null) { var xsessions_path = Path.build_filename ("/usr/share/xsessions/", session.concat(".desktop"), null); var wsessions_path = Path.build_filename ("/usr/share/wayland-sessions/", session.concat(".desktop"), null); diff --git a/src/settings.vala b/src/settings.vala index acef828..7c4bd84 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -73,6 +73,8 @@ public class AGSettings : Object public const string KEY_MENUBAR_ALPHA = "menubar-alpha"; public const string KEY_HIDE_X11_SESSIONS = "hide-x11-sessions"; public const string KEY_HIDE_WAYLAND_SESSIONS = "hide-wayland-sessions"; + public const string KEY_INCLUDEONLY_SESSIONS = "includeonly-sessions"; + 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"; |