From f2cd533ae9f99296f64550494e3587cd67f3c363 Mon Sep 17 00:00:00 2001 From: clsty Date: Wed, 12 Nov 2025 17:11:14 +0800 Subject: [PATCH] Add subcmd virtmon (WIP) --- sdata/subcmd-virtmon/0.run.sh | 13 +++++++++++++ sdata/subcmd-virtmon/options.sh | 33 +++++++++++++++++++++++++++++++++ setup | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 sdata/subcmd-virtmon/0.run.sh create mode 100644 sdata/subcmd-virtmon/options.sh diff --git a/sdata/subcmd-virtmon/0.run.sh b/sdata/subcmd-virtmon/0.run.sh new file mode 100644 index 000000000..efcd53b21 --- /dev/null +++ b/sdata/subcmd-virtmon/0.run.sh @@ -0,0 +1,13 @@ +# This script is meant to be sourced. +# It's not for directly running. + +# shellcheck shell=bash + +readarray -t vmon < <(hyprctl -j monitors all | jq -r '.[] | select(.name | test("^HEADLESS-")) | .name') + +if [ "${#vmon[@]}" -gt 0 ]; then + printf '%s\n' "${vmon[@]}" +else + echo "no headless monitors found" >&2 + exit 1 +fi diff --git a/sdata/subcmd-virtmon/options.sh b/sdata/subcmd-virtmon/options.sh new file mode 100644 index 000000000..be001ea39 --- /dev/null +++ b/sdata/subcmd-virtmon/options.sh @@ -0,0 +1,33 @@ +# Handle args for subcmd: checkdeps +# shellcheck shell=bash + +showhelp(){ +echo -e "Syntax: $0 virtmon [OPTIONS] + +Create virtual monitor for testing multi-monitors. + +Options: + -h, --help Show this help message +" +} +# `man getopt` to see more +para=$(getopt \ + -o h \ + -l help \ + -n "$0" -- "$@") +[ $? != 0 ] && echo "$0: Error when getopt, please recheck parameters." && exit 1 +##################################################################################### +eval set -- "$para" +while true ; do + case "$1" in + -h|--help) showhelp;exit;; + --) shift;break ;; + *) sleep 0 ;; + esac +done + +#if [[ -f "$1" ]]; then +# echo "Using list file \"$1\".";LIST_FILE_PATH="$1";shift 1 +#else +# echo "Wrong path \"$1\" of list file.";exit 1 +#fi diff --git a/setup b/setup index 4ea77f2c0..662abdca0 100755 --- a/setup +++ b/setup @@ -34,6 +34,7 @@ Subcommands: exp-update-old (Experimental) exp-update but use behaves like old version. checkdeps (For dev only) Check whether pkgs exist in AUR or repos of Arch. + virtmon (For dev only, WIP) Create virtual monitors for testing multi-monitors. help Show this help message. For each , use -h for details: @@ -46,7 +47,7 @@ case $1 in # Global help ""|help|--help|-h)showhelp_global;exit;; # Correct subcommand - install|exp-uninstall|exp-update|exp-update-old|checkdeps) + install|exp-uninstall|exp-update|exp-update-old|checkdeps|virtmon) SUBCMD_NAME=$1 SUBCMD_DIR=./sdata/subcmd-$1 shift;;