-
Notifications
You must be signed in to change notification settings - Fork 0
/
screen-layout
executable file
·45 lines (37 loc) · 1.52 KB
/
screen-layout
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
#!/bin/bash
set -e
MAIN_SCREEN=LVDS1
MAIN_SCREEN_RESOLUTION=1920x1080
#MAIN_SCREEN_RESOLUTION=$(xrandr | grep $MAIN_SCREEN | sed -n 's/.* \([0-9]\+x[0-9]\+\)+.*/\1/p')
#MAIN_SCREEN_RESOLUTION_AND_PANNING=$(xrandr | grep $MAIN_SCREEN | sed -n 's/.* \([0-9]\+x[0-9]\++[0-9]\++[0-9]\+\).*/\1/p')
connected_screens() {
xrandr | sed -n 's/\([-a-zA-Z0-9]\+\) connected.*/\1/p' | grep -v "$MAIN_SCREEN" | xargs
}
CONNECTED_SCREENS=$(connected_screens)
if [ -z "$CONNECTED_SCREENS" ]; then
echo "No connected screens found"
else
for screen in $CONNECTED_SCREENS; do
echo "Configuring $screen:"
select MODE in mirror above off; do
case $MODE in
mirror)
xrandr --output $screen --off
xrandr --output $screen --auto
xrandr --output $MAIN_SCREEN --primary --auto --same-as $screen --mode $MAIN_SCREEN_RESOLUTION
;;
above)
screen_resolution=$(xrandr | grep $screen | sed -n 's/.* \([0-9]\+x[0-9]\+\)+.*/\1/p')
xrandr --nograb --output $screen --mode $screen_resolution
# xrandr --nograb --output $screen --panning 0x0+0+0
xrandr --nograb --output $screen --panning $screen_resolution+0+0/0x0+0+0/0/0/0/-1200
xrandr --output $MAIN_SCREEN --primary --auto --below $screen --panning 0x0+0+0/0x0+0+0 # --auto
;;
off)
xrandr --output $screen --off
;;
esac
exit 0
done
done
fi