diff options
| author | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-26 22:23:04 +0100 |
|---|---|---|
| committer | sommerfeld <sommerfeld@sommerfeld.dev> | 2026-09-26 22:23:04 +0100 |
| commit | 869ea8436d9cf9d5748e6c089cc0b0b58358e75f (patch) | |
| tree | 57d765d0a975b67573673f13d00a1584cb2c35f4 /dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js | |
| parent | d6f4aee0ccf47dea61204f4af44d8eed2e65f96c (diff) | |
| download | dotfiles-869ea8436d9cf9d5748e6c089cc0b0b58358e75f.tar.gz dotfiles-869ea8436d9cf9d5748e6c089cc0b0b58358e75f.tar.bz2 dotfiles-869ea8436d9cf9d5748e6c089cc0b0b58358e75f.zip | |
Align GNOME shortcuts with the Sway setup
Diffstat (limited to 'dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js')
| -rw-r--r-- | dot_local/share/gnome-shell/extensions/workspace-cycle@dotfiles/extension.js | 35 |
1 files changed, 35 insertions, 0 deletions
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"); + } +} |
