54 lines
1.5 KiB
Bash
Executable File
54 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
get_current_workspace() {
|
|
hyprctl activeworkspace | head -n 1 | cut -d ' ' -f 3
|
|
}
|
|
|
|
get_current_monitor() {
|
|
hyprctl activeworkspace | head -n 1 | rev | cut -d ' ' -f 1 | rev | tr -d ':'
|
|
}
|
|
|
|
get_nth_workspace() {
|
|
cat /home/thomas/.config/hypr/hyprland.conf \
|
|
| grep "^workspace =" \
|
|
| grep $1 \
|
|
| sed "${2}q;d" \
|
|
| cut -d '=' -f 2 \
|
|
| cut -d ',' -f 1 \
|
|
| tr -d ' '
|
|
}
|
|
|
|
case "$1" in
|
|
"workspace")
|
|
current_monitor=$(get_current_monitor)
|
|
workspace=$(get_nth_workspace $current_monitor $2)
|
|
hyprctl dispatch workspace $workspace;;
|
|
|
|
"movetoworkspace")
|
|
current_monitor=$(get_current_monitor)
|
|
workspace=$(get_nth_workspace $current_monitor $2)
|
|
hyprctl dispatch movetoworkspace $workspace;;
|
|
|
|
"previous")
|
|
current_monitor=$(get_current_monitor)
|
|
current_workspace=$(get_current_workspace)
|
|
previous_workspace=$(($current_workspace - 1))
|
|
|
|
if [[ "$previous_workspace" == *0 ]]; then
|
|
previous_workspace=$(($previous_workspace + 10))
|
|
fi
|
|
|
|
hyprctl dispatch workspace $previous_workspace;;
|
|
|
|
"next")
|
|
current_monitor=$(get_current_monitor)
|
|
current_workspace=$(get_current_workspace)
|
|
next_workspace=$(($current_workspace + 1))
|
|
|
|
if [[ "$next_workspace" == *1 ]]; then
|
|
next_workspace=$(($next_workspace - 10))
|
|
fi
|
|
|
|
hyprctl dispatch workspace $next_workspace;;
|
|
esac
|