diff --git a/.local/bin/xmonconf b/.local/bin/xmonconf index 647b16a..5eeeeff 100755 --- a/.local/bin/xmonconf +++ b/.local/bin/xmonconf @@ -65,15 +65,20 @@ monitor_exist() { # monitors_exist checks if the specified monitors are connected to the system # $1..$n: The monitor names to search for monitors_exist() { - local monitor + local monitor matches=0 for monitor in "$@"; do - if ! monitor_exist "$monitor"; then - return 1 + if monitor_exist "$monitor"; then + echo "$monitor" + matches=$((matches + 1)) fi done - echo "Monitors exist: ${*}" + if [ "$matches" -ne "$#" ]; then + echo "Amount of devices does not match the amount of arguments" 1>&2 + return 1 + fi + return 0 } @@ -303,7 +308,7 @@ main() { for monitor in "${monitors[@]}"; do IFS=',' read -r -a monitor_array <<<"$monitor" - if monitors_exist "${monitor_array[@]}"; then + if monitors_exist "${monitor_array[@]}" >/dev/null; then echo "Applying dock profile for ${monitor_array[*]}" xrandr \ --output "${monitor_array[0]}" --mode 1920x1200 --rotate normal --pos 1200x1474 --primary \