Skip to content

Commit

Permalink
Don't check for updates in demo mode (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored Oct 29, 2024
1 parent 6e9dd0c commit c5fd1da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Backends/SystemUpdate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
}

public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {
if (SettingsDaemon.Utils.is_running_in_demo_mode () && !force) {
return;
}

if (current_state.state != UP_TO_DATE && current_state.state != AVAILABLE && !force) {
return;
}
Expand Down
23 changes: 23 additions & 0 deletions src/Utils/SessionUtils.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace SettingsDaemon.Utils {
public static bool is_running_in_demo_mode () {
var proc_cmdline = File.new_for_path ("/proc/cmdline");
try {
var @is = proc_cmdline.read ();
var dis = new DataInputStream (@is);

var line = dis.read_line ();
if ("boot=casper" in line || "boot=live" in line || "rd.live.image" in line) {
return true;
}
} catch (Error e) {
critical ("Couldn't detect if running in Demo Mode: %s", e.message);
}

return false;
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sources = files(
'Backends/PrefersColorSchemeSettings.vala',
'Backends/SystemUpdate.vala',
'Utils/PkUtils.vala',
'Utils/SessionUtils.vala',
'Utils/SunriseSunsetCalculator.vala',
)

Expand Down

0 comments on commit c5fd1da

Please sign in to comment.