summaryrefslogtreecommitdiff
path: root/toggle-workspace@jodersky.github.com/extension.js
diff options
context:
space:
mode:
Diffstat (limited to 'toggle-workspace@jodersky.github.com/extension.js')
-rw-r--r--toggle-workspace@jodersky.github.com/extension.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/toggle-workspace@jodersky.github.com/extension.js b/toggle-workspace@jodersky.github.com/extension.js
new file mode 100644
index 0000000..6da69b3
--- /dev/null
+++ b/toggle-workspace@jodersky.github.com/extension.js
@@ -0,0 +1,39 @@
+
+const St = imports.gi.St;
+const Main = imports.ui.main;
+const Meta = imports.gi.Meta;
+const Shell = imports.gi.Shell;
+const Utils = imports.misc.extensionUtils.getCurrentExtension().imports.util;
+
+let primary, saved;
+
+function _toggleWorkspace() {
+ let current = global.screen.get_active_workspace().index();
+ if (current == primary) {
+ global.screen.get_workspace_by_index(saved).activate(global.get_current_time());
+ } else {
+ global.screen.get_workspace_by_index(primary).activate(global.get_current_time());
+ saved = current;
+ }
+}
+
+function init() {
+ primary = 0;
+ saved = 1;
+}
+
+function enable() {
+ Main.wm.addKeybinding(
+ 'toggle-primary-workspace',
+ Utils.getSettings(),
+ Meta.KeyBindingFlags.NONE,
+ Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.MESSAGE_TRAY,
+ function() {
+ _toggleWorkspace();
+ }
+ );
+}
+
+function disable() {
+ Main.wm.removeKeybinding('toggle-primary-workspace');
+} \ No newline at end of file