#!/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() { current_workspace=$1 if [[ "$current_workspace" == *0 ]]; then current_workspace=$(($current_workspace - 10)) fi workspace=$(echo $current_workspace | cut -c 1)$2 if [[ "$workspace" == *0 ]]; then workspace=$(($workspace + 10)) fi echo $workspace } case "$1" in "cpustat") head -n 1 ~/.config/dotfiles/hypr/.stat.txt;; "memstat") tail -n 1 ~/.config/dotfiles/hypr/.stat.txt;; "workspace") current_workspace=$(get_current_workspace) workspace=$(get_nth_workspace $current_workspace $2) hyprctl dispatch workspace $workspace;; "movetoworkspace") current_workspace=$(get_current_workspace) workspace=$(get_nth_workspace $current_workspace $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;; esac