mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-13 22:02:34 +00:00
feat: Adds switch-to-workspace script, so that moving workspaces will toggle a special workspace if it's active.
This commit is contained in:
22
env/.config/hypr/keybinds.conf
vendored
22
env/.config/hypr/keybinds.conf
vendored
@@ -34,7 +34,7 @@ $housecallPro = https://pro.housecallpro.com/app/calendar_new
|
||||
bindd = $mainMod, SPACE, Application launcher, exec, $menu
|
||||
bindd = $mainMod, RETURN, New terminal, exec, $terminal
|
||||
bindd = $mainMod SHIFT, RETURN, New floating terminal, exec, $terminal --class=com.ghostty.float
|
||||
bindd = $mainMod, TAB, Focus previous workspace, workspace, previous
|
||||
bindd = $mainMod, TAB, Focus previous workspace, exec, $scripts/switch-to-workspace previous #workspace, previous
|
||||
bindd = $mainMod, A, [A]i - launch / focus, exec, $pwa --or-focus "https://chatgpt.com"
|
||||
bindd = $mainMod SHIFT, A, [A]i - new window, exec, $pwa "https://chatgpt.com"
|
||||
bindd = $mainMod, B, New [b]rowser, exec, $browser
|
||||
@@ -69,16 +69,16 @@ bindd = $mainMod, W, Close current window, killac
|
||||
bindd = $mainMod SHIFT, W, Close all windows in active workspace, exec, $scripts/close-windows --active-workspace
|
||||
|
||||
# Switch to workspaces with mainMod + [0-9]
|
||||
bindd = $mainMod, 1, Switch to workspace [1], workspace, 1
|
||||
bindd = $mainMod, 2, Switch to workspace [2], workspace, 2
|
||||
bindd = $mainMod, 3, Switch to workspace [3], workspace, 3
|
||||
bindd = $mainMod, 4, Switch to workspace [4], workspace, 4
|
||||
bindd = $mainMod, 5, Switch to workspace [5], workspace, 5
|
||||
bindd = $mainMod, 6, Switch to workspace [6], workspace, 6
|
||||
bindd = $mainMod, 7, Switch to workspace [7], workspace, 7
|
||||
bindd = $mainMod, 8, Switch to workspace [8], workspace, 8
|
||||
bindd = $mainMod, 9, Switch to workspace [9], workspace, 9
|
||||
bindd = $mainMod, 0, Switch to workspace 1[0], workspace, 10
|
||||
bindd = $mainMod, 1, Switch to workspace [1], exec, $scripts/switch-to-workspace 1
|
||||
bindd = $mainMod, 2, Switch to workspace [2], exec, $scripts/switch-to-workspace 2
|
||||
bindd = $mainMod, 3, Switch to workspace [3], exec, $scripts/switch-to-workspace 3
|
||||
bindd = $mainMod, 4, Switch to workspace [4], exec, $scripts/switch-to-workspace 4
|
||||
bindd = $mainMod, 5, Switch to workspace [5], exec, $scripts/switch-to-workspace 5
|
||||
bindd = $mainMod, 6, Switch to workspace [6], exec, $scripts/switch-to-workspace 6
|
||||
bindd = $mainMod, 7, Switch to workspace [7], exec, $scripts/switch-to-workspace 7
|
||||
bindd = $mainMod, 8, Switch to workspace [8], exec, $scripts/switch-to-workspace 8
|
||||
bindd = $mainMod, 9, Switch to workspace [9], exec, $scripts/switch-to-workspace 9
|
||||
bindd = $mainMod, 0, Switch to workspace 1[0], exec, $scripts/switch-to-workspace 10
|
||||
|
||||
# Move all workspaces to a monitor
|
||||
bindd = $mainMod SHIFT, 1, Switch all workspaces to monitor [1], exec, $scripts/mv-all-workspaces-to-monitor 1
|
||||
|
||||
54
env/.local/scripts/hypr/switch-to-workspace
vendored
Executable file
54
env/.local/scripts/hypr/switch-to-workspace
vendored
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
|
||||
Switch to the given workspace. Toggling off a special workspaces if active window is on a
|
||||
special workspace.
|
||||
|
||||
The builtin way in hyprland does not toggle off special workspaces, so the workspace just
|
||||
changes underneath the special workspace, whereas this script ensures that you switch to
|
||||
the workspace.
|
||||
|
||||
USAGE:
|
||||
|
||||
$ $(basename ${BASH_SOURCE[0]}) [OPTIONS] <workspace>
|
||||
|
||||
OPTIONS:
|
||||
|
||||
-h | --help: Show this help page.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
target_workspace=""
|
||||
active_workspace=$(hyprctl activewindow -j | jq -r '.workspace.name')
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
|
||||
usage && exit 0
|
||||
else
|
||||
target_workspace=$1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ -z target_workspace ]]; then
|
||||
echo "[ERROR]: Must supply a workpsace to switch to."
|
||||
usage && exit 1
|
||||
fi
|
||||
|
||||
# If active window is on a special workspace, then toggle the special workspace off.
|
||||
if [[ $active_workspace =~ ^special ]]; then
|
||||
echo "Toggling special workspace: '$active_workspace'"
|
||||
hyprctl dispatch togglespecialworkspace ${active_workspace#special:}
|
||||
|
||||
# Only toggle the special workspace if trying to switch to previous and we're currently
|
||||
# on a special workspace.
|
||||
if [[ $target_workspace == "previous" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Switching to workspace: $target_workspace"
|
||||
hyprctl dispatch workspace $target_workspace
|
||||
Reference in New Issue
Block a user