dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 7d318d6d9db5276c870d15d1f3af7cafab0c8488
parent 1ce5e3219ee64524419c3e7a2debbe81522ce882
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Sun, 23 Dec 2018 17:07:04 +0100

Allow mirroring between internal and external display, with scaling for internal display

Diffstat:
Mlinks/bin/displayselect | 27++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/links/bin/displayselect b/links/bin/displayselect @@ -6,13 +6,30 @@ # I plan on adding a routine from multi-monitor setups later. twoscreen() { # If multi-monitor is selected and there are two screens. + mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?") + # Mirror displays using native resolution of external display and a scaled + # version for the internal display if [ "$mirror" = "yes" ]; then - screen1=$(echo "$screens" | head -n 1) - screen2=$(echo "$screens" | tail -n 1) + external=$(echo "$screens" | dmenu -i -p "Select external display:") + internal=$(echo "$screens" | grep -v "$external") + + res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \ + tail -n 1 | awk '{print $1}') + + res_ext_x=$(echo $res_external | sed 's/x.*//') + res_ext_y=$(echo $res_external | sed 's/.*x//') + res_int_x=$(echo $res_internal | sed 's/x.*//') + res_int_y=$(echo $res_internal | sed 's/.*x//') + + scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l) + scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l) - xrandr --output "$screen1" \ - --output "$screen2" --same-as "$screen1" + xrandr --output "$external" --auto \ + --output "$internal" --auto --same-as "$external" \ + --scale "$scale_x"x"$scale_y" else primary=$(echo "$screens" | dmenu -i -p "Select primary display:") @@ -62,7 +79,7 @@ if [ $(echo "$screens" | wc -l) -gt 1 ]; then case "$chosen" in "manual selection") arandr ; exit ;; "multi-monitor") multimon ;; - *) xrandr --output "$chosen" --auto $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; + *) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$screens" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;; esac fi