From 869ea8436d9cf9d5748e6c089cc0b0b58358e75f Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Sat, 26 Sep 2026 22:23:04 +0100 Subject: Align GNOME shortcuts with the Sway setup --- .../workspace-cycle@dotfiles/extension.js | 35 ++++++++++++++++++++++ .../workspace-cycle@dotfiles/metadata.json | 8 +++++ ...me.shell.extensions.workspace-cycle.gschema.xml | 13 ++++++++ 3 files changed, 56 insertions(+) create mode 100644 dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js create mode 100644 dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/metadata.json create mode 100644 dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/schemas/org.gnome.shell.extensions.workspace-cycle.gschema.xml (limited to 'dot_local/share') diff --git a/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js new file mode 100644 index 0000000..dc6e3c9 --- /dev/null +++ b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js @@ -0,0 +1,35 @@ +import Meta from "gi://Meta"; +import Shell from "gi://Shell"; +import { Extension } from "resource:///org/gnome/shell/extensions/extension.js"; +import * as Main from "resource:///org/gnome/shell/ui/main.js"; + +export default class WorkspaceCycle extends Extension { + enable() { + const settings = this.getSettings(); + for (const [name, step] of [ + ["next-workspace", 1], + ["previous-workspace", -1], + ]) { + Main.wm.addKeybinding( + name, + settings, + Meta.KeyBindingFlags.NONE, + Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW, + () => this.cycle(step), + ); + } + } + + cycle(step) { + const manager = global.workspace_manager; + const count = manager.n_workspaces; + if (count < 2) return; + const index = (manager.get_active_workspace_index() + step + count) % count; + manager.get_workspace_by_index(index).activate(global.get_current_time()); + } + + disable() { + Main.wm.removeKeybinding("next-workspace"); + Main.wm.removeKeybinding("previous-workspace"); + } +} diff --git a/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/metadata.json b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/metadata.json new file mode 100644 index 0000000..8f8eafd --- /dev/null +++ b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/metadata.json @@ -0,0 +1,8 @@ +{ + "uuid": "workspace-cycle@dotfiles", + "name": "Workspace Cycle", + "description": "Cycle through workspaces in both directions.", + "shell-version": ["50"], + "settings-schema": "org.gnome.shell.extensions.workspace-cycle", + "version": 1 +} diff --git a/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/schemas/org.gnome.shell.extensions.workspace-cycle.gschema.xml b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/schemas/org.gnome.shell.extensions.workspace-cycle.gschema.xml new file mode 100644 index 0000000..25a993f --- /dev/null +++ b/dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/schemas/org.gnome.shell.extensions.workspace-cycle.gschema.xml @@ -0,0 +1,13 @@ + + + + + [] + Next workspace, with wraparound + + + [] + Previous workspace, with wraparound + + + -- cgit v1.3.1