Add option to mirror displays with external resolution priority
This commit is contained in:
parent
6922946855
commit
8e27c7f4b8
1 changed files with 32 additions and 5 deletions
|
@ -6,10 +6,37 @@
|
||||||
# I plan on adding a routine from multi-monitor setups later.
|
# I plan on adding a routine from multi-monitor setups later.
|
||||||
|
|
||||||
twoscreen() { # If multi-monitor is selected and there are two screens.
|
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
|
||||||
|
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 "$external" --auto \
|
||||||
|
--output "$internal" --auto --same-as "$external" \
|
||||||
|
--scale "$scale_x"x"$scale_y"
|
||||||
|
else
|
||||||
|
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary")
|
secondary=$(echo "$screens" | grep -v "$primary")
|
||||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
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
|
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||||
|
|
Loading…
Reference in a new issue