forked from Shinonome/dots-hyprland
Update virtmon
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <IP>:<Port> 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 <IP>:<Port> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user