Skip to content

Commit

Permalink
Revert "MainWindow: Better detect when running in live session (#733)" (
Browse files Browse the repository at this point in the history
#736)

This reverts commit c4c9e69.
  • Loading branch information
danirabbit authored Jun 3, 2024
1 parent 4c6992b commit 7541666
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
private int current_user_card_index = 0;
private unowned Greeter.BaseCard? current_card = null;

private bool? _is_live_session = null;
private bool is_live_session {
get {
if (_is_live_session != null) {
return _is_live_session;
}

_is_live_session = false;

var proc_cmdline = File.new_for_path ("/proc/cmdline");
try {
var dis = new DataInputStream (proc_cmdline.read ());
var line = dis.read_line ();
if ("boot=casper" in line || "boot=live" in line || "rd.live.image" in line) {
_is_live_session = true;
}
} catch (Error e) {
critical ("Couldn't detect if running in Live Session: %s", e.message);
}

return _is_live_session;
}
}
private bool installer_mode = false;

private Gtk.EventControllerKey key_controller;

Expand Down Expand Up @@ -408,7 +386,7 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {

// If the greeter is running on the install medium, check if the Installer has signalled
// that it wants the greeter to launch the live (demo) session by means of touching a file
if (is_live_session) {
if (installer_mode) {
var demo_mode_file = File.new_for_path ("/var/lib/lightdm/demo-mode");
if (demo_mode_file.query_exists ()) {
demo_mode_file.@delete ();
Expand Down Expand Up @@ -453,15 +431,19 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
critical (e.message);
}

// Don't need to build user cards etc in live media
if (is_live_session) {
return;
}
lightdm_greeter.notify_property ("show-manual-login-hint");
lightdm_greeter.notify_property ("has-guest-account-hint");

if (lightdm_greeter.default_session_hint != null) {
get_action_group ("session").activate_action ("select", new GLib.Variant.string (lightdm_greeter.default_session_hint));
}

// Check if the installer is installed
var installer_desktop = new DesktopAppInfo ("io.elementary.installer.desktop");
if (installer_desktop != null) {
installer_mode = true;
}

if (lightdm_user_list.length > 0) {
datetime_revealer.reveal_child = true;

Expand Down Expand Up @@ -515,8 +497,6 @@ public class Greeter.MainWindow : Gtk.ApplicationWindow {
}

lightdm_greeter.notify_property ("hide-users-hint");
lightdm_greeter.notify_property ("show-manual-login-hint");
lightdm_greeter.notify_property ("has-guest-account-hint");
}

private void add_card (LightDM.User lightdm_user) {
Expand Down

0 comments on commit 7541666

Please sign in to comment.