forked from Shinonome/dots-hyprland
Add hypr_mon_guard
This commit is contained in:
@@ -5,6 +5,21 @@
|
||||
|
||||
ensure_cmds wayvnc lsof jq ip
|
||||
|
||||
enable_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."
|
||||
PATH=$PATH:${REPO_ROOT}/sdata/subcmd-virtmon setsid hypr_mon_guard > $(mktemp) 2>&1 &
|
||||
else
|
||||
echo "Script hypr_mon_guard not found."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
if [[ "${ENABLE_HYPR_MON_GUARD}" = true ]]; then
|
||||
enable_hypr_mon_guard
|
||||
fi
|
||||
|
||||
readarray -t vmon_ids < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^TESTER-")) | .name | sub("^TESTER-"; "")')
|
||||
|
||||
if [[ "${CLEAN_TESTER_MONITORS}" = true ]]; then
|
||||
@@ -43,7 +58,7 @@ vmon_tester=TESTER-$vnc_port
|
||||
echo "Creating tester monitor..."
|
||||
x hyprctl output create headless ${vmon_tester}
|
||||
|
||||
echo "Setting geometry..."
|
||||
echo "Setting properties of tester monitor..."
|
||||
x hyprctl keyword monitor ${vmon_tester},${VMON_RESOLUTION}@${VMON_FPS},${VMON_POSITION},${VMON_SCALE}${VMON_EXTRA}
|
||||
|
||||
e="%s${STY_RST}\n"
|
||||
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
# This script is to prevent hyprland from not responding to any input when no monitor is enabled.
|
||||
# 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')
|
||||
#if -z "$enabled_mons"; then
|
||||
if [ ${#enabled_mons[@]} -eq 0 ]; then
|
||||
hyprctl reload
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
@@ -21,6 +21,8 @@ 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.
|
||||
|
||||
For the syntax of following options, see also Hyprland Wiki:
|
||||
https://wiki.hypr.land/Configuring/Monitors
|
||||
@@ -29,7 +31,7 @@ For the syntax of following options, see also Hyprland Wiki:
|
||||
--pos <pos> Position, by default ${STY_UNDERLINE}$VMON_POSITION${STY_RST}
|
||||
Examples: ${STY_UNDERLINE}auto-left${STY_RST}, ${STY_UNDERLINE}0x-1080${STY_RST}
|
||||
--sca <sca> Scale, by default ${STY_UNDERLINE}$VMON_SCALE${STY_RST}
|
||||
--ext <ext> Extra args, e.g. ${STY_UNDERLINE}transform, 1${STY_RST}
|
||||
--ext <ext> Extra properties, e.g. ${STY_UNDERLINE}transform, 1${STY_RST}
|
||||
|
||||
Tip: Recommended VNC client:
|
||||
- Android: AVNC (https://github.com/gujjwal00/avnc)
|
||||
@@ -39,8 +41,8 @@ Tip: Recommended VNC client:
|
||||
}
|
||||
# `man getopt` to see more
|
||||
para=$(getopt \
|
||||
-o hcd \
|
||||
-l help,clean,daemon,res:,fps:,pos:,sca:,ext: \
|
||||
-o hcdg \
|
||||
-l help,clean,daemon,guard,res:,fps:,pos:,sca:,ext: \
|
||||
-n "$0" -- "$@")
|
||||
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
|
||||
#####################################################################################
|
||||
@@ -58,6 +60,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;;
|
||||
--res) VMON_RESOLUTION="$2";shift 2;;
|
||||
--fps) VMON_FPS="$2";shift 2;;
|
||||
--pos) VMON_POSITION="$2";shift 2;;
|
||||
|
||||
Reference in New Issue
Block a user