From 061438f139af66a768cd38e17f5aa2a977b47fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 30 Jul 2026 04:36:15 +0300 Subject: [PATCH] fix(hyprland/scripts): drop swapactiveworkspaces, add monitors-on menu show_desktop.sh: swapactiveworkspaces moved the wrong workspace when the two monitors were not both occupied. Focus each monitor and switch its workspace explicitly, and handle the single-monitor case. toggle_monitors.sh: the menu could only turn outputs off. HDMI-A-1 uses `keyword monitor disable/enable` rather than dpms, which dpms cannot undo. --- .config/scripts/hyprland/show_desktop.sh | 18 ++++++++++++------ .config/scripts/hyprland/toggle_monitors.sh | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.config/scripts/hyprland/show_desktop.sh b/.config/scripts/hyprland/show_desktop.sh index a66c5fc..8fea66a 100755 --- a/.config/scripts/hyprland/show_desktop.sh +++ b/.config/scripts/hyprland/show_desktop.sh @@ -4,9 +4,11 @@ STATE_FILE="/tmp/hypr_show_desktop" if [ -f "$STATE_FILE" ]; then source "$STATE_FILE" - hyprctl dispatch workspace "$WS_OTHER" - hyprctl dispatch swapactiveworkspaces "$MON1" "$MON2" - hyprctl dispatch workspace "$WS_FOCUSED" + if [ -n "$MON2" ]; then + hyprctl --batch "dispatch focusmonitor $MON2; dispatch workspace $WS_OTHER; dispatch focusmonitor $MON1; dispatch workspace $WS_FOCUSED" + else + hyprctl dispatch workspace "$WS_FOCUSED" + fi rm "$STATE_FILE" else mon_json=$(hyprctl monitors -j) @@ -22,7 +24,11 @@ WS_FOCUSED=$WS_FOCUSED WS_OTHER=$WS_OTHER EOF - hyprctl dispatch workspace 998 - hyprctl dispatch swapactiveworkspaces "$MON1" "$MON2" - hyprctl dispatch workspace 999 + # one empty dummy workspace per monitor; no swapactiveworkspaces — + # swaps rebind workspaces to the wrong monitor and confuse waybar + if [ -n "$MON2" ]; then + hyprctl --batch "dispatch focusmonitor $MON2; dispatch workspace 998; dispatch focusmonitor $MON1; dispatch workspace 999" + else + hyprctl dispatch workspace 999 + fi fi diff --git a/.config/scripts/hyprland/toggle_monitors.sh b/.config/scripts/hyprland/toggle_monitors.sh index fd2a0af..17cf4ac 100755 --- a/.config/scripts/hyprland/toggle_monitors.sh +++ b/.config/scripts/hyprland/toggle_monitors.sh @@ -7,7 +7,7 @@ HDMI_CONFIG="HDMI-A-1, 1920x1080@75, 2560x0, 1, bitdepth, 10" case "${1:-menu}" in menu) - menu=$(echo -e "šŸ–„ļø All Monitors Off\nšŸ–„ļø DP-1 Off\nšŸ–„ļø HDMI-A-1 Off\nāŒ Cancel" | rofi -dmenu -p "Monitors" -i) + menu=$(echo -e "šŸ–„ļø All Monitors Off\nšŸ–„ļø DP-1 Off\nšŸ–„ļø HDMI-A-1 Off\nšŸ’” All Monitors On\nšŸ’” DP-1 On\nšŸ’” HDMI-A-1 On\nāŒ Cancel" | rofi -dmenu -p "Monitors" -i) case "$menu" in "šŸ–„ļø All Monitors Off") @@ -19,7 +19,17 @@ case "${1:-menu}" in hyprctl dispatch dpms off DP-1 ;; "šŸ–„ļø HDMI-A-1 Off") - hyprctl dispatch dpms off HDMI-A-1 + hyprctl keyword monitor "HDMI-A-1, disable" + ;; + "šŸ’” All Monitors On") + hyprctl dispatch dpms on DP-1 + hyprctl keyword monitor "$HDMI_CONFIG" + ;; + "šŸ’” DP-1 On") + hyprctl dispatch dpms on DP-1 + ;; + "šŸ’” HDMI-A-1 On") + hyprctl keyword monitor "$HDMI_CONFIG" ;; "āŒ Cancel") ;;