summaryrefslogtreecommitdiffstats
path: root/.scripts/i3cmds/displayselect
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/i3cmds/displayselect')
-rwxr-xr-x.scripts/i3cmds/displayselect39
1 files changed, 33 insertions, 6 deletions
diff --git a/.scripts/i3cmds/displayselect b/.scripts/i3cmds/displayselect
index c5f751a..0bd612e 100755
--- a/.scripts/i3cmds/displayselect
+++ b/.scripts/i3cmds/displayselect
@@ -6,11 +6,38 @@
# I plan on adding a routine from multi-monitor setups later.
twoscreen() { # If multi-monitor is selected and there are two screens.
- primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
- secondary=$(echo "$screens" | grep -v "$primary")
- direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
- xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto
- }
+
+ 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
+ external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
+ 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 "$external" --auto --scale 1.0x1.0 \
+ --output "$internal" --auto --same-as "$external" \
+ --scale "$scale_x"x"$scale_y"
+ else
+
+ primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
+ secondary=$(echo "$screens" | grep -v "$primary")
+ direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
+ xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
+ fi
+ }
morescreen() { # If multi-monitor is selected and there are more than two screens.
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
@@ -38,7 +65,7 @@ chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p
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
# Fix feh background if screen size/arangement has changed.