[gnome-shell/benzea/systemd-clean-shutdown-with-extension-disabling: 1/2] extensionSystem: Create a file to flag that extensions are being loaded



commit 47ed52c799299034418b67c9745eaf619e711071
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Nov 25 21:20:02 2019 +0100

    extensionSystem: Create a file to flag that extensions are being loaded
    
    When the extension system is loaded, create the
    gnome-shell-disable-extensions file in the users runtime directory. This
    file is automatically removed 60s later. The sole purpose of this file
    is to be consumed by the systemd units. If the file exists, the systemd
    units will disable extensions when the gnome-shell fails.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/858

 js/ui/extensionSystem.js | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index c56bfdf059..743beba0c5 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -1,7 +1,7 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 /* exported init connect disconnect */
 
-const { Gio, St } = imports.gi;
+const { GLib, Gio, St } = imports.gi;
 const Signals = imports.signals;
 
 const ExtensionUtils = imports.misc.extensionUtils;
@@ -28,6 +28,23 @@ var ExtensionManager = class {
     }
 
     init() {
+        // The following file should exist for a period of time when extensions
+        // are enabled after start. If it exists, then the systemd unit will
+        // disable extensions should gnome-shell crash.
+        // Should the file already exist from a previous login, then this is OK.
+        let extension_disable_filename = GLib.build_filenamev([GLib.get_user_runtime_dir(), 
'gnome-shell-disable-extensions']);
+        let extension_disable_file = Gio.File.new_for_path(extension_disable_filename);
+        try {
+            extension_disable_file.create(Gio.FileCreateFlags.REPLACE_DESTINATION, null);
+        } catch (e) {
+            log(`Failed to create file ${extension_disable_filename}: ${e.message}`);
+        }
+
+        GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => {
+            FileUtils.deleteGFile(extension_disable_file);
+            return GLib.SOURCE_REMOVE;
+        });
+
         this._sessionUpdated();
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]