mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
68 lines
1.6 KiB
Bash
Executable File
68 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
THIS_FILE=${BASH_SOURCE[0]}
|
|
LOG_LABEL=$(basename $THIS_FILE)
|
|
LOG_FILE=${LOG_FILE:-/tmp/$LOG_LABEL.log}
|
|
THIS=${THIS:-$LOG_LABEL}
|
|
|
|
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:
|
|
|
|
$ $THIS [OPTIONS] <workspace>
|
|
|
|
OPTIONS:
|
|
|
|
-h | --help: Show this help page.
|
|
|
|
EOF
|
|
}
|
|
|
|
target_workspace=""
|
|
active_workspace=$(hyprctl activewindow -j | jq -r '.workspace.name')
|
|
SCRIPTS=${SCRIPTS:-$HOME/.local/scripts}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
if [[ $1 =~ ^-h ]] || [[ $1 =~ ^--help ]]; then
|
|
usage && exit 0
|
|
else
|
|
target_workspace=$1
|
|
fi
|
|
shift
|
|
done
|
|
|
|
log() {
|
|
logging log --source "$THIS_FILE" "$@"
|
|
}
|
|
|
|
source "$SCRIPTS/hypr/logging"
|
|
setup-logging "$LOG_FILE" "$LOG_LABEL"
|
|
|
|
if [[ -z target_workspace ]]; then
|
|
log --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
|
|
log "Toggling special workspace: '$active_workspace'"
|
|
hyprctl dispatch togglespecialworkspace ${active_workspace#special:} >/dev/null 2>&1
|
|
|
|
# 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
|
|
|
|
log "Switching to workspace: $target_workspace"
|
|
hyprctl dispatch workspace $target_workspace >/dev/null 2>&1
|