diff options
author | Clement Lefebvre <clement.lefebvre@linuxmint.com> | 2017-06-20 15:20:08 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-06-20 15:20:08 +0200 |
commit | ba46af16e693fa86f9270d5e9135a2381a8a62f9 (patch) | |
tree | 1f54e0d3844d2b5c998b525e7d50b86b25facfc1 /src | |
parent | 2fa9791d9802d5c34323d9bd99ad9fa608abdda6 (diff) | |
download | arctica-greeter-ba46af16e693fa86f9270d5e9135a2381a8a62f9.tar.gz arctica-greeter-ba46af16e693fa86f9270d5e9135a2381a8a62f9.tar.bz2 arctica-greeter-ba46af16e693fa86f9270d5e9135a2381a8a62f9.zip |
Add support for validating session names (and proper fallback for uninstalled sessions). Ported from slick-greeter.
Diffstat (limited to 'src')
-rw-r--r-- | src/arctica-greeter.vala | 46 | ||||
-rw-r--r-- | src/greeter-list.vala | 2 | ||||
-rw-r--r-- | src/user-list.vala | 2 |
3 files changed, 48 insertions, 2 deletions
diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index 9b5d279..eb42306 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -181,6 +181,52 @@ public class ArcticaGreeter ctx.add_class ("lightdm"); } + public static string? get_default_session () + { + var sessions = new List<string> (); + sessions.append ("lightdm-xsession"); + + // FIXME: this list should be obtained from AGSettings, ideally... + sessions.append ("mate"); + sessions.append ("xfce"); + sessions.append ("kde-plasma"); + sessions.append ("kde"); + sessions.append ("gnome"); + sessions.append ("cinnamon"); + + foreach (string session in sessions) { + var path = Path.build_filename ("/usr/share/xsessions/", session.concat(".desktop"), null); + if (FileUtils.test (path, FileTest.EXISTS)) { + return session; + } + } + + warning ("Could not find a default session."); + return null; + } + + public static string validate_session (string? session) + { + /* 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); + if (!FileUtils.test (path, FileTest.EXISTS) ) { + debug ("Invalid session: '%s'", session); + session = null; + } + } + + if (session == null) { + var default_session = ArcticaGreeter.get_default_session (); + debug ("Invalid session: '%s'. Using session '%s' instead.", session, default_session); + return default_session; + } + + return session; + } + public bool start_session (string? session, Background bg) { /* Explicitly set the right scale before closing window */ diff --git a/src/greeter-list.vala b/src/greeter-list.vala index 17d80a8..8e25602 100644 --- a/src/greeter-list.vala +++ b/src/greeter-list.vala @@ -947,7 +947,7 @@ public abstract class GreeterList : FadableBox protected virtual string get_lightdm_session () { - return "ubuntu"; + return ArcticaGreeter.get_default_session (); } /* Testing code below this */ diff --git a/src/user-list.vala b/src/user-list.vala index ad68a17..319e833 100644 --- a/src/user-list.vala +++ b/src/user-list.vala @@ -859,7 +859,7 @@ public class UserList : GreeterList } e.background = background; e.is_active = is_active; - e.session = session; + e.session = ArcticaGreeter.validate_session(session); e.label = label; e.set_show_message_icon (has_messages); e.set_is_active (is_active); |