Update virtmon

This commit is contained in:
clsty
2025-11-12 17:37:28 +08:00
parent 3f8c62a81b
commit a250675b5c
2 changed files with 36 additions and 7 deletions
+24 -5
View File
@@ -3,11 +3,30 @@
# shellcheck shell=bash
readarray -t vmon < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^HEADLESS-")) | .name')
readarray -t vmons < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^HEADLESS-")) | .name')
if [ "${#vmon[@]}" -gt 0 ]; then
printf '%s\n' "${vmon[@]}"
if [ "${#vmons[@]}" -gt 0 ]; then
echo "headless monitors found:"
printf '%s\n' "${vmons[@]}"
if [[ ! "${KEEP_VIRTUAL_MONITORS}" = true ]]; then
echo "Cleaning..."
for i in "${vmons[@]}"; do
x hyprctl output remove "$i"
done
fi
else
echo "no headless monitors found" >&2
exit 1
echo "No headless monitors found."
fi
echo "Creating headless monitor..."
readarray -t vmons_old < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^HEADLESS-")) | .name')
x hyprctl output create headless
readarray -t vmons_new < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^HEADLESS-")) | .name')
#echo "Setting geometry..."
#${vmon_new}
echo "Using wayvnc to share monitor..."
wayvnc -o=${vmon_new} --log-level=trace 0.0.0.0 5901
echo "Cleaning the new headless monitor..."
x hyprctl output remove "${vmon_new}"
+12 -2
View File
@@ -8,12 +8,13 @@ Create virtual monitor for testing multi-monitors.
Options:
-h, --help Show this help message
-k, --keep Do not remove virtual monitors
"
}
# `man getopt` to see more
para=$(getopt \
-o h \
-l help \
-o hk \
-l help,keep \
-n "$0" -- "$@")
[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1
#####################################################################################
@@ -26,6 +27,15 @@ while true ; do
esac
done
eval set -- "$para"
while true ; do
case "$1" in
-k|--keep) KEEP_VIRTUAL_MONITORS=true;shift;;
--) shift;break ;;
*) sleep 0 ;;
esac
done
#if [[ -f "$1" ]]; then
# echo "Using list file \"$1\".";LIST_FILE_PATH="$1";shift 1
#else