blob: 480e1bd62b1167b96a71aa952045f416ea499153 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh
# Craig Jennings
# convenience script to switch monitors
# this script assumes there are at most two monitors attached and we want to switch between then
CHOICES="Laptop\nLaptop-Scaled\nHome-Display\nExternal-Auto\nExternal-Scaled\nVirtualbox"
# laptops always have a monitor connected when running the script.
LAPTOP=$(xrandr -q | grep primary | awk '$2 == "connected" {print $1}')
echo "primary monitor is $LAPTOP"
# an external monitor will always be a connected monitor that isn't primary
EXTERNAL=$(xrandr -q | grep -v primary | awk '$2 == "connected" {print $1}')
# start by resetting
xrandr -s 0
# disable if called automatically, otherwise you'll want the menu
# if there's only one monitor connected, setup laptop monitor
# if [ -z "$EXTERNAL" ]; then
# xrandr -s 0
# xrandr --output "$LAPTOP" --auto --dpi 144 --scale 0.6
# exit 0
# fi
CHOSEN=$(echo -e "$CHOICES" | dmenu -i)
case "$CHOSEN" in
"Laptop")
xrandr --output "$LAPTOP" --auto --output "$EXTERNAL" --off
;;
"Laptop-Scaled")
xrandr --output "$LAPTOP" --auto --dpi 144 --scale 0.6 --output "$EXTERNAL" --off
;;
"External")
xrandr --output "$EXTERNAL" --auto --dpi 96 --mode 3440x1440 --scale 1.0 --output "$LAPTOP" --off
;;
"External-Auto")
xrandr --output "$EXTERNAL" --auto --output "$LAPTOP" --off
;;
"External-Scaled")
xrandr --output "$EXTERNAL" --auto --scale 0.6 --output "$LAPTOP" --off
;;
"Virtualbox")
xrandr --output "$LAPTOP" --auto --mode 1920x1080
;;
esac
# restore the wallpaper after resolution change
nitrogen --restore
|