aboutsummaryrefslogtreecommitdiff
path: root/src/arctica-greeter.vala
diff options
context:
space:
mode:
authorClement Lefebvre <clement.lefebvre@linuxmint.com>2017-06-20 15:20:08 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-06-20 15:20:08 +0200
commitba46af16e693fa86f9270d5e9135a2381a8a62f9 (patch)
tree1f54e0d3844d2b5c998b525e7d50b86b25facfc1 /src/arctica-greeter.vala
parent2fa9791d9802d5c34323d9bd99ad9fa608abdda6 (diff)
downloadarctica-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/arctica-greeter.vala')
-rw-r--r--src/arctica-greeter.vala46
1 files changed, 46 insertions, 0 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 */