diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-04-03 17:07:57 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-04-03 17:07:57 +0200 |
commit | 2614224219792ae5baabb2e958ce768fdd4a7758 (patch) | |
tree | 20e6e0aaaacf4241e4eb85595a469db8d5419fad /src | |
parent | c9a2d903518d8d35e85437c5263e558992080cb1 (diff) | |
download | arctica-greeter-2614224219792ae5baabb2e958ce768fdd4a7758.tar.gz arctica-greeter-2614224219792ae5baabb2e958ce768fdd4a7758.tar.bz2 arctica-greeter-2614224219792ae5baabb2e958ce768fdd4a7758.zip |
Add support for hiding X11 and/or Wayland sessions.
Diffstat (limited to 'src')
-rw-r--r-- | src/arctica-greeter.vala | 47 | ||||
-rw-r--r-- | src/background.vala | 3 | ||||
-rw-r--r-- | src/session-list.vala | 7 | ||||
-rw-r--r-- | src/settings.vala | 3 |
4 files changed, 41 insertions, 19 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 19e3b4d..c765151 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -223,19 +223,23 @@ public class ArcticaGreeter : Object sessions.append ("cinnamon"); sessions.append ("lomiri"); - foreach (string session in sessions) { - 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_WAYLAND_SESSIONS)) { + foreach (string session in sessions) { + 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; + } } } - foreach (string session in sessions) { - 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; + if (!AGSettings.get_boolean (AGSettings.KEY_HIDE_X11_SESSIONS)) { + foreach (string session in sessions) { + 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; + } } } @@ -243,21 +247,34 @@ public class ArcticaGreeter : Object return greeter.default_session_hint; } - public string validate_session (string? session) + public string validate_session (string? session, bool? fallback = true) { /* Make sure the given session actually exists. Return it if it does. * otherwise, return the default session. */ if (session != null) { - var path = Path.build_filename ("/usr/share/xsessions/", session.concat(".desktop"), null); - var waypath = Path.build_filename ("/usr/share/wayland-sessions/", session.concat(".desktop"), null); - if (!FileUtils.test (path, FileTest.EXISTS) & !FileUtils.test (waypath, FileTest.EXISTS)) { + 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); + + if (AGSettings.get_boolean (AGSettings.KEY_HIDE_WAYLAND_SESSIONS) & + FileUtils.test (wsessions_path, FileTest.EXISTS)) { + debug ("Wayland session hidden: '%s'", session); + session = null; + } + else if (AGSettings.get_boolean (AGSettings.KEY_HIDE_X11_SESSIONS) & + FileUtils.test (xsessions_path, FileTest.EXISTS)) { + debug ("X11 session hidden: '%s'", session); + session = null; + } + else if (!FileUtils.test (xsessions_path, FileTest.EXISTS) & + !FileUtils.test (wsessions_path, FileTest.EXISTS)) + { debug ("Invalid session: '%s'", session); session = null; } } - if (session == null) { + if ((fallback == true) & (session == null)) { var default_session = get_default_session (); debug ("Invalid session: '%s'. Using session '%s' instead.", session, default_session); return default_session; diff --git a/src/background.vala b/src/background.vala index 18bf169..31d3057 100644 --- a/src/background.vala +++ b/src/background.vala @@ -206,8 +206,9 @@ class BackgroundLoader : Object if (logo != null) { bc.save (); + var x = (int) grid_x_offset + 1.5 * grid_size; var y = (int) (image.height / grid_size - 2) * grid_size + grid_y_offset; - bc.translate (grid_x_offset, y); + bc.translate (x, y); bc.set_source_surface (logo, 0, 0); bc.paint_with_alpha (0.5); bc.restore (); diff --git a/src/session-list.vala b/src/session-list.vala index 878f20a..21e9eb6 100644 --- a/src/session-list.vala +++ b/src/session-list.vala @@ -55,8 +55,11 @@ public class SessionPrompt : PromptBox { foreach (var session in sessions_sorted_ci( LightDM.get_sessions() ) ) { - debug ("Adding session %s (%s)", session.key, session.name); - box.add_item (session.key, session.name, SessionList.get_badge (session.key)); + /* 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)); + } } } diff --git a/src/settings.vala b/src/settings.vala index ecc01c4..d347813 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -67,7 +67,8 @@ public class AGSettings : Object public const string KEY_FLATBUTTON_BORDERCOLOR = "flatbutton-bordercolor"; public const string KEY_ENABLE_HIDPI = "enable-hidpi"; 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 static bool get_boolean (string key) { |