From 06ca7eecaac4bbb6c53b47981be0b268eaf2a527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Wed, 10 Jan 2018 09:42:58 +0100 Subject: [PATCH] Pass settings object to `killKeybinding` Restoration require the same settings object to be available due to the use of Map. Indexing on the canonical name of the schema is probably a better solution. --- extension.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/extension.js b/extension.js index 9535340..69879f8 100644 --- a/extension.js +++ b/extension.js @@ -23,6 +23,9 @@ let isDuringGnomeShellStartup = false; window.PaperWM = Extension; +var wmSettings; +var shellSettings; +var paperSettings; var paperActions; function init() { SESSIONID += "#" @@ -35,6 +38,12 @@ function init() { } initCount++; + wmSettings = + new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings"}); + + shellSettings = new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"}); + paperSettings = convenience.getSettings(); + /* Keep track of some mappings mutter doesn't do/expose - action-name -> action-id mapping @@ -157,7 +166,6 @@ function restoreKeybindings() { } } -var settings; let nWorkspacesSignal; let workspaceRemovedSignal; let windowCreatedSignal; @@ -197,6 +205,8 @@ function enable() { initWorkspaces(); } + // Restore settings if we've reloaded + restoreKeybindings(paperSettings); let settings = new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings"}); @@ -205,13 +215,12 @@ function enable() { settings.set_strv("toggle-fullscreen", ['f']); // We want to use - killKeybinding('switch-applications'); - killKeybinding('switch-applications-backward'); - killKeybinding('switch-group'); - killKeybinding('switch-group-backward'); + killKeybinding('switch-applications', wmSettings); + killKeybinding('switch-applications-backward', wmSettings); + killKeybinding('switch-group', wmSettings); + killKeybinding('switch-group-backward', wmSettings); - let shell_settings = new Gio.Settings({ schema_id: "org.gnome.shell.keybindings"}); - shell_settings.set_strv("toggle-overview", ["space"]) + shellSettings.set_strv("toggle-overview", ["space"]) enabled = true; } @@ -225,7 +234,12 @@ function disable() { Tiling.disable(); StackOverlay.disable() - restoreKeybindings(); + // Restore default gnome bindings + restoreKeybindings(wmSettings); + + // Kill our custom bindings + killKeybinding('live-alt-tab', paperSettings) + killKeybinding('live-alt-tab-backward', paperSettings) enabled = false; }