forked from Shinonome/dots-hyprland
workspace_action.sh: make comments not weird
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
curr_workspace="$(hyprctl activeworkspace -j | jq -r ".id")" ##parses json output of hyprctl activeworkspace on the active monitor
|
curr_workspace="$(hyprctl activeworkspace -j | jq -r ".id")"
|
||||||
dispatcher="$1"
|
dispatcher="$1"
|
||||||
shift ##Any dispatcher that hyprland supports, the shift shifts the target such that target is now in $1, not $2
|
shift ## The target is now in $1, not $2
|
||||||
|
|
||||||
if [[ -z "${dispatcher}" || "${dispatcher}" == "--help" || "${dispatcher}" == "-h" || -z "$1" ]]; then
|
if [[ -z "${dispatcher}" || "${dispatcher}" == "--help" || "${dispatcher}" == "-h" || -z "$1" ]]; then
|
||||||
echo "Usage: $0 <dispatcher> <target>"
|
echo "Usage: $0 <dispatcher> <target>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ "$1" == *"+"* || "$1" == *"-"* ]]; then ##pattern matching (works with r+1 and +1 only aswell)
|
if [[ "$1" == *"+"* || "$1" == *"-"* ]]; then ## Is this something like r+1 or -1?
|
||||||
hyprctl dispatch "${dispatcher}" "$1" ##$1 = workspace id since we shifted earlier.
|
hyprctl dispatch "${dispatcher}" "$1" ## $1 = workspace id since we shifted earlier.
|
||||||
elif [[ "$1" =~ ^[0-9]+$ ]]; then ##Regex matching
|
elif [[ "$1" =~ ^[0-9]+$ ]]; then ## Is this just a number?
|
||||||
target_workspace=$(((($curr_workspace - 1) / 10 ) * 10 + $1))
|
target_workspace=$(((($curr_workspace - 1) / 10 ) * 10 + $1))
|
||||||
hyprctl dispatch "${dispatcher}" "${target_workspace}"
|
hyprctl dispatch "${dispatcher}" "${target_workspace}"
|
||||||
else
|
else
|
||||||
hyprctl dispatch "${dispatcher}" "$1" ##Incase the target in a string, required for special workspaces.
|
hyprctl dispatch "${dispatcher}" "$1" ## In case the target in a string, required for special workspaces.
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user