#!/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_next_monitor() { current_monitor=$(get_current_monitor) next_monitor=$(hyprctl monitors | grep Monitor | grep " $current_monitor " -A 2 | sed '2q;d' | cut -d ' ' -f 2) if [ -z $next_monitor ]; then next_monitor=$(hyprctl monitors | grep Monitor | head -n 1 | cut -d ' ' -f 2) fi echo $next_monitor } get_previous_monitor() { current_monitor=$(get_current_monitor) previous_monitor=$(hyprctl monitors | grep Monitor | grep " $current_monitor " -B 2 | sed '2q;d' | cut -d ' ' -f 2) if [ -z $previous_monitor ]; then previous_monitor=$(hyprctl monitors | grep Monitor | tail -n 1 | cut -d ' ' -f 2) fi echo $previous_monitor } 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;; "movewindow") next_monitor=$(get_next_monitor) hyprctl dispatch movewindow mon:$next_monitor;; "focuspreviousmonitor") previous_monitor=$(get_previous_monitor) hyprctl dispatch focusmonitor $previous_monitor;; "focusnextmonitor") next_monitor=$(get_next_monitor) hyprctl dispatch focusmonitor $next_monitor;; "reload") systemctl restart waybar --user hyprctl reload;; esac