From: Ian Kelling Date: Fri, 21 Jun 2024 13:47:05 +0000 (-0400) Subject: myx fix for different resolutions X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=d4f5bab91b40e325b79e6698579484971f03d81f;p=distro-setup myx fix for different resolutions --- diff --git a/myx b/myx index 99d889f..f3aefe6 100755 --- a/myx +++ b/myx @@ -94,49 +94,12 @@ move-ws() { date "+%A, %B %d, %r, %S seconds" -##### begin command line parsing ######## dry_run=false downres=true quarter=true tall=false restart=false -temp=$(getopt -l help fnrs: "$@") || usage 1 -eval set -- "$temp" -while true; do - case $1 in - -f) - downres=false - quarter=false - tall=false - ;; - -n) dry_run=true ;; - -s) - case $2 in - tall) - tall=true - quarter=false - ;; - quarter) - tall=false - quarter=true - ;; - full) - tall=false - quarter=false - ;; - esac - shift - ;; - -r) restart=true ;; - -h|--help) usage 0 ;; - --) shift; break ;; - *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;; - esac - shift -done - -##### end command line parsing ######## xf=$(mktemp) @@ -147,11 +110,6 @@ if $dry_run; then m() { printf "$script_name: %s\n" "$*"; } fi -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 secondary_out=$(awk '$2 == "connected" && $3 != "primary" {print $1}' $xf) @@ -167,12 +125,6 @@ primary_y=${primary_res#*x} if [[ $secondary_out ]]; then - # some monitors need off then on to become active - if $restart; then - m xrandr --output $secondary_out --off - m sleep 2 - fi - x_offset=$primary_x left_right_arg=--right-of if [[ $secondary_out == HDMI2 && $(edid card0-HDMI-A-2) == 192efbdcef ]] || \ @@ -189,8 +141,6 @@ if [[ $secondary_out ]]; then target_x=${target_res%x*} target_y=${target_res#*x} else - # disables any leftover secondary. - xrandr --auto target_out=$primary_out x_offset=0 target_res=$primary_res @@ -198,25 +148,89 @@ else target_y=$primary_y fi + if (( target_x <= 1280 )); then quarter=false tall=false +elif (( target_x <= 1920 )); then + quarter=false + tall=true fi if $downres && (( target_x > 2560 )); then target_x=2560 target_y=1440 target_res=${target_x}x$target_y - if [[ $secondary_out || $primary_res != "$target_res" ]]; then - m xrandr --output $target_out $left_right_arg --mode $target_res +fi + + +half_x=$(( target_x / 2 )) +half_y=$(( target_y / 2 )) + + + +##### begin command line parsing ######## + +temp=$(getopt -l help fnrs: "$@") || usage 1 +eval set -- "$temp" +while true; do + case $1 in + -f) + downres=false + quarter=false + tall=false + ;; + -n) dry_run=true ;; + -s) + case $2 in + tall) + tall=true + quarter=false + ;; + quarter) + tall=false + quarter=true + ;; + full) + tall=false + quarter=false + ;; + esac + shift + ;; + -r) restart=true ;; + -h|--help) usage 0 ;; + --) shift; break ;; + *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;; + esac + shift +done + +##### end command line parsing ######## + +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 ]]; then + if $restart; then + m xrandr --output $secondary_out --off + m sleep 2 fi else + # disables any leftover secondary. + xrandr --auto +fi + +if [[ $secondary_out || $primary_res != "$target_res" ]]; then m xrandr --output $target_out $left_right_arg --mode $target_res fi -half_x=$(( target_x / 2 )) -half_y=$(( target_y / 2 )) +m /a/bin/ds/i3-sway/gen if $tall; then @@ -241,7 +255,6 @@ else # fullscreen move-ws $target_out 2 3 5 6 7 8 9 10 fi -m /a/bin/ds/i3-sway/gen m /a/exe/input-setup echo -n "myx end: "