From 0917ee65f2a695f44c4bcbd868b7d3917d49a3c0 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 13 Nov 2025 01:20:14 +0800 Subject: [PATCH] Enable hypr_mon_guard by default --- sdata/subcmd-virtmon/0.run.sh | 6 +++--- sdata/subcmd-virtmon/hypr_mon_guard | 2 ++ sdata/subcmd-virtmon/options.sh | 9 ++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sdata/subcmd-virtmon/0.run.sh b/sdata/subcmd-virtmon/0.run.sh index 160743931..3b0426909 100644 --- a/sdata/subcmd-virtmon/0.run.sh +++ b/sdata/subcmd-virtmon/0.run.sh @@ -5,7 +5,7 @@ ensure_cmds wayvnc lsof jq ip -enable_hypr_mon_guard(){ +start_hypr_mon_guard(){ if ! pgrep -x hypr_mon_guard >/dev/null 2>&1; then if PATH=$PATH:${REPO_ROOT}/sdata/subcmd-virtmon command -v hypr_mon_guard ; then echo "Running hypr_mon_guard." @@ -16,8 +16,8 @@ enable_hypr_mon_guard(){ fi fi } -if [[ "${ENABLE_HYPR_MON_GUARD}" = true ]]; then - enable_hypr_mon_guard +if ! [[ "${DISABLE_HYPR_MON_GUARD}" = true ]]; then + start_hypr_mon_guard fi readarray -t vmon_ids < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^TESTER-")) | .name | sub("^TESTER-"; "")') diff --git a/sdata/subcmd-virtmon/hypr_mon_guard b/sdata/subcmd-virtmon/hypr_mon_guard index f2ae9a41f..299cf63be 100755 --- a/sdata/subcmd-virtmon/hypr_mon_guard +++ b/sdata/subcmd-virtmon/hypr_mon_guard @@ -1,5 +1,7 @@ #!/usr/bin/bash # This script is to prevent hyprland from not responding to any input when no monitor is enabled. +# When this script is running in background, +# it will be safe to temporarily disable monitors using hyprctl. # The shebang cannot be #!/usr/bin/env bash , idk why while true; do readarray -t enabled_mons < <(hyprctl -j monitors all | jq -r '.[] | select(.disabled == false) | .name') diff --git a/sdata/subcmd-virtmon/options.sh b/sdata/subcmd-virtmon/options.sh index 9f95d06ec..6e67d396c 100644 --- a/sdata/subcmd-virtmon/options.sh +++ b/sdata/subcmd-virtmon/options.sh @@ -21,8 +21,7 @@ Options: -h, --help Show this help message and exit -c, --clean Clean all tester monitors and wayvnc sessions and exit -d, --daemon Run in background - -g, --guard Enable hypr_mon_guard so it will be safe to - temporarily disable monitors using hyprctl. + --no-guard Disable hypr_mon_guard For the syntax of following options, see also Hyprland Wiki: https://wiki.hypr.land/Configuring/Monitors @@ -41,8 +40,8 @@ Tip: Recommended VNC client: } # `man getopt` to see more para=$(getopt \ - -o hcdg \ - -l help,clean,daemon,guard,res:,fps:,pos:,sca:,ext: \ + -o hcd \ + -l help,clean,daemon,no-guard,res:,fps:,pos:,sca:,ext: \ -n "$0" -- "$@") [ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1 ##################################################################################### @@ -60,7 +59,7 @@ while true ; do case "$1" in -c|--clean) CLEAN_TESTER_MONITORS=true;shift;; -d|--daemon) RUNNING_IN_BACKGROUND=true;shift;; - -g|--guard) ENABLE_HYPR_MON_GUARD=true;shift;; + --no-guard) DISABLE_HYPR_MON_GUARD=true;shift;; --res) VMON_RESOLUTION="$2";shift 2;; --fps) VMON_FPS="$2";shift 2;; --pos) VMON_POSITION="$2";shift 2;;