aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arctica-greeter.vala46
-rw-r--r--src/greeter-list.vala2
-rw-r--r--src/user-list.vala2
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);