From e2428035ca6693e5a5d3beaa7849ffec3a52f892 Mon Sep 17 00:00:00 2001 From: Nikolai Papin Date: Sat, 27 Sep 2025 03:10:45 +0300 Subject: [PATCH] feat: mirror display toggle --- hypr/hyprland.conf | 6 +++--- hypr/scripts/toggle_mirror_display.sh | 22 ++++++++++++++++++++++ swaync/config.json | 6 ++++++ 3 files changed, 31 insertions(+), 3 deletions(-) create mode 100755 hypr/scripts/toggle_mirror_display.sh diff --git a/hypr/hyprland.conf b/hypr/hyprland.conf index dbc8c5c..380814b 100644 --- a/hypr/hyprland.conf +++ b/hypr/hyprland.conf @@ -3,8 +3,8 @@ ################ # See https://wiki.hyprland.org/Configuring/Monitors/ -monitor=eDP-1, 1920x1080, 0x0, 1 -monitor=HDMI-A-1, 1920x1080, -1920x-100, 1 +# monitor=eDP-1, 1920x1080, 0x0, 1 +# monitor=HDMI-A-1, 1920x1080, -1920x-100, 1 ################### ### MY PROGRAMS ### @@ -663,4 +663,4 @@ debug { disable_logs = false } -# source = ~/.config/hypr/monitors.conf +source = ~/.config/hypr/monitors.conf diff --git a/hypr/scripts/toggle_mirror_display.sh b/hypr/scripts/toggle_mirror_display.sh new file mode 100755 index 0000000..f32de6f --- /dev/null +++ b/hypr/scripts/toggle_mirror_display.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Define the file to modify +FILE="$HOME/.config/hypr/monitors.conf" + +# Get the last line of the file +LAST_LINE=$(tail -n 1 "$FILE") + +# Check if the first argument is "g" +if [ "$1" = "g" ]; then + [[ $LAST_LINE == \#* ]] && echo false || echo true + exit 0 +fi + +# Check if the last line is commented +if [[ $LAST_LINE == \#* ]]; then + # Uncomment the last line + sed -i '$s/^# //' "$FILE" +else + # Comment the last line + sed -i '$s/^/# /' "$FILE" +fi diff --git a/swaync/config.json b/swaync/config.json index e6ff659..4d7c2be 100644 --- a/swaync/config.json +++ b/swaync/config.json @@ -148,6 +148,12 @@ "type": "toggle", "command": "[[ $SWAYNC_TOGGLE_STATE == true ]] && ( systemd-inhibit --why='User request via swaync' --what=sleep:handle-lid-switch:idle sh -c 'echo \"$$\" > \"$XDG_RUNTIME_DIR/swaync-idle.pid\"; while true; do sleep 3600; done' ) || kill $(<\"$XDG_RUNTIME_DIR/swaync-idle.pid\")", "update-command": "kill -0 $(<\"$XDG_RUNTIME_DIR/swaync-idle.pid\") && echo true || echo false" + }, + { + "label": "󱞟", + "type": "toggle", + "command": "sh -c 'exec ~/.config/hypr/scripts/toggle_mirror_display.sh'", + "update-command": "sh -c 'exec ~/.config/hypr/scripts/toggle_mirror_display.sh g'" } ] },