Thanks to autorandr I don't need the script anymore.
This commit is contained in:
parent
c88e516616
commit
9259bf7026
@ -1,56 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
twoscreen() {
|
||||
mirror=$(printf "no\\nyes" | dmenu -c -l 2 -i -p "mirror?")
|
||||
if [ "$mirror" = "yes" ]; then
|
||||
external=$(echo "$screens" | dmenu -c -l 2 -i)
|
||||
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 -c -l 50 -i -p "select primary output")
|
||||
secondary=$(echo "$screens" | grep -v "$primary")
|
||||
direction=$(printf "left\\nright" | dmenu -c -l 2 -i -p "secondary display location")
|
||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||
fi
|
||||
}
|
||||
|
||||
onescreen() {
|
||||
if [ "$2" = "native" ]; then
|
||||
xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -)
|
||||
else
|
||||
scale=$(printf "native\\n0.75\\n0.5" | dmenu -c -l 3 -i -p "scale") &&
|
||||
case "$scale" in
|
||||
"native") xrandr --output "$1" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
||||
*) xrandr --output "$1" --auto --scale ${scale}x${scale} $(echo "$allposs" | grep -v "\b$1" | awk '{print "--output", $1, "--off"}' | paste -sd ' ' -);;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# Get all possible displays
|
||||
allposs=$(xrandr -q | grep "connected")
|
||||
|
||||
# Get all connected screens.
|
||||
screens=$(echo "$allposs" | awk '/ connected/ {print $1}')
|
||||
|
||||
# If there's only one screen
|
||||
[ "$(echo "$screens" | wc -l)" -lt 2 ] &&
|
||||
{ onescreen "$screens" "native"; notify-send -t 2000 -u critical ' no device to switch'; exit ;}
|
||||
|
||||
# Get user choice including both and manual selection:
|
||||
chosen=$(printf -- "%s\\nmulti" "$screens" | dmenu -c -l 5 -i -p "select output") &&
|
||||
case "$chosen" in
|
||||
"multi") twoscreen ;;
|
||||
*) onescreen "$chosen" ;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user