From: Ian Kelling Date: Sat, 22 Jun 2024 04:44:52 +0000 (-0400) Subject: fix dryrun logic X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=1e6046bc6e8399382b8ceecd0c376b789e1df0f0;p=distro-setup fix dryrun logic --- diff --git a/myx b/myx index f3aefe6..79b9fad 100755 --- a/myx +++ b/myx @@ -105,10 +105,13 @@ restart=false xf=$(mktemp) xrandr >$xf -m() { printf "$script_name: %s\n" "$*"; "$@"; } -if $dry_run; then - m() { printf "$script_name: %s\n" "$*"; } -fi +m() { + if $dry_run; then + printf "$script_name: dry run: %s\n" "$*" + else + printf "$script_name: %s\n" "$*"; "$@" + fi +} @@ -157,17 +160,6 @@ elif (( target_x <= 1920 )); then tall=true fi -if $downres && (( target_x > 2560 )); then - target_x=2560 - target_y=1440 - target_res=${target_x}x$target_y -fi - - -half_x=$(( target_x / 2 )) -half_y=$(( target_y / 2 )) - - ##### begin command line parsing ######## @@ -208,21 +200,32 @@ done ##### end command line parsing ######## + +if $downres && (( target_x > 2560 )); then + target_x=2560 + target_y=1440 + target_res=${target_x}x$target_y +fi + + +half_x=$(( target_x / 2 )) +half_y=$(( target_y / 2 )) + + for mon_suffix in TOP-LEFT BOTTOM-LEFT LEFT RIGHT; do if xrandr --listmonitors | awk '$2 == "MON-'$mon_suffix\" |grep . >/dev/null; then m xrandr --delmonitor MON-$mon_suffix fi done +if [[ ! $secondary_out ]] || grep -A1 disconnected $xf | grep '^[[:space:]]'; then + # gets rid of leftover secondary + m xrandr --auto +fi -if [[ $secondary_out ]]; then - if $restart; then - m xrandr --output $secondary_out --off - m sleep 2 - fi -else - # disables any leftover secondary. - xrandr --auto +if [[ $secondary_out ]] && $restart; then + m xrandr --output $secondary_out --off + m sleep 2 fi if [[ $secondary_out || $primary_res != "$target_res" ]]; then