From 5696a4348e9b8cbdfccf78e6bb840d78f3385705 Mon Sep 17 00:00:00 2001 From: clsty Date: Wed, 12 Nov 2025 21:54:08 +0800 Subject: [PATCH] Update virtmon --- sdata/subcmd-checkdeps/options.sh | 3 +- sdata/subcmd-install/options.sh | 4 +-- sdata/subcmd-resetfirstrun/options.sh | 2 +- sdata/subcmd-virtmon/0.run.sh | 41 ++++++++++++++------------- sdata/subcmd-virtmon/options.sh | 4 +-- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/sdata/subcmd-checkdeps/options.sh b/sdata/subcmd-checkdeps/options.sh index 562b2e364..b5d0dbcd0 100644 --- a/sdata/subcmd-checkdeps/options.sh +++ b/sdata/subcmd-checkdeps/options.sh @@ -16,13 +16,14 @@ para=$(getopt \ -l help \ -n "$0" -- "$@") [ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1 +echo $para ##################################################################################### eval set -- "$para" while true ; do case "$1" in -h|--help) showhelp;exit;; --) shift;break ;; - *) sleep 0 ;; + *) echo -e "$0: Wrong parameters.";exit 1;; esac done diff --git a/sdata/subcmd-install/options.sh b/sdata/subcmd-install/options.sh index c5e860215..5d843d83d 100644 --- a/sdata/subcmd-install/options.sh +++ b/sdata/subcmd-install/options.sh @@ -55,7 +55,7 @@ while true ; do case "$1" in -h|--help) showhelp;exit;; -c|--clean) cleancache;shift;; - --) break ;; + --) shift;break ;; *) shift ;; esac done @@ -93,7 +93,7 @@ while true ; do fi;; ## Ending - --) break ;; + --) shift;break ;; *) echo -e "$0: Wrong parameters.";exit 1;; esac done diff --git a/sdata/subcmd-resetfirstrun/options.sh b/sdata/subcmd-resetfirstrun/options.sh index e5def7d2b..51b08f63a 100644 --- a/sdata/subcmd-resetfirstrun/options.sh +++ b/sdata/subcmd-resetfirstrun/options.sh @@ -22,6 +22,6 @@ while true ; do case "$1" in -h|--help) showhelp;exit;; --) shift;break ;; - *) sleep 0 ;; + *) echo -e "$0: Wrong parameters.";exit 1;; esac done diff --git a/sdata/subcmd-virtmon/0.run.sh b/sdata/subcmd-virtmon/0.run.sh index 446978e62..989c6dfc2 100644 --- a/sdata/subcmd-virtmon/0.run.sh +++ b/sdata/subcmd-virtmon/0.run.sh @@ -9,12 +9,15 @@ readarray -t vmon_ids < <(hyprctl -j monitors all | jq -r '.[] | select(.name | if [[ "${CLEAN_TESTER_MONITORS}" = true ]]; then echo "Cleaning tester monitors..." - for i in "TESTER-${vmon_ids[@]}"; do - x hyprctl output remove "$i" + for i in "${vmon_ids[@]}"; do + echo "Removing tester monitor: TESTER-$i..." + x hyprctl output remove "TESTER-$i" done echo "Cleaning tester wayvnc sessions..." - for tester_socket in /tmp/wayvncctl_tester_* ; do - x wayvncctl --socket=$tester_socket -r wayvnc-exit + for i in /tmp/wayvncctl_tester_* ; do + # When no target is matched, * will not be expanded + [ -e "$i" ] || continue + x bash -c "wayvncctl --socket=$i -r wayvnc-exit || rm $i" done echo "Cleaning complete, exit..." exit 0 @@ -35,7 +38,7 @@ fi tester_socket=/tmp/wayvncctl_tester_$vnc_port # In case this exists for some reason try rm $tester_socket -vmon_tester=TESTER-$vnc_port;break +vmon_tester=TESTER-$vnc_port echo "Creating tester monitor..." x hyprctl output create headless ${vmon_tester} @@ -43,22 +46,22 @@ x hyprctl output create headless ${vmon_tester} echo "Setting geometry..." x hyprctl keyword monitor ${vmon_tester},${VMON_RESOLUTION}@${VMON_FPS},${VMON_POSITION},${VMON_SCALE}${VMON_EXTRA} -echo "=========================================" -echo "Use a VNC client to connect to the virtual monitor." -echo " Port: $vnc_port" -echo " IP: choose a suitable one from below:" -ip -o addr show up | grep -v -E 'docker|veth|virbr' | awk '{split($4,a,"/"); print $2"\t"a[1]}' -echo "The status of the virtual monitor:" -echo " Resolution: ${VMON_RESOLUTION}" -echo " Frame rate: ${VMON_FPS}" -echo "Hint:" -echo " The VNC client will ask you about server address," -echo " either joined as : or separately." -echo " As for username and password, just leave them as empty." -echo "=========================================" -echo "Launching wayvnc..." +printf "%s\n" "=========================================" +printf "%s\n" "Use a VNC client to connect to the virtual monitor." +printf "%s\n" " Port: $vnc_port" +printf "%s\n" " IP: choose a suitable one from below:" +LANG=C LC_ALL=C ip -o addr show up | grep -v -E 'docker|veth|virbr' | awk '{split($4,a,"/"); print $2"\t"a[1]}' +printf "%s\n" "The status of the virtual monitor:" +printf "%s\n" " Resolution: ${VMON_RESOLUTION}" +printf "%s\n" " Frame rate: ${VMON_FPS}" +printf "%s\n" "Hint:" +printf "%s\n" " The VNC client will ask you about server address," +printf "%s\n" " either joined as : or separately." +printf "%s\n" " As for username and password, just leave them as empty." +printf "%s\n" "=========================================" if [ "$RUNNING_IN_BACKGROUND" = true ];then + echo "wayvnc now running in background. Run again with --clean to cleanup." nohup wayvnc --socket=$tester_socket -f=${VMON_FPS} -o=${vmon_tester} --log-level=${WAYVNC_LOGLEVEL} 0.0.0.0 $vnc_port > $(mktemp) 2>&1 & disown else diff --git a/sdata/subcmd-virtmon/options.sh b/sdata/subcmd-virtmon/options.sh index 6fd721617..c9f9a43e7 100644 --- a/sdata/subcmd-virtmon/options.sh +++ b/sdata/subcmd-virtmon/options.sh @@ -41,7 +41,7 @@ while true ; do case "$1" in -h|--help) showhelp;exit;; --) shift;break ;; - *) sleep 0 ;; + *) shift ;; esac done @@ -56,6 +56,6 @@ while true ; do --sca) VMON_SCALE="$2";shift 2;; --ext) VMON_EXTRA=", $2";shift 2;; --) shift;break ;; - *) sleep 0 ;; + *) echo -e "$0: Wrong parameters.";exit 1;; esac done