blob: 9d80383fe7252d26398465d9cac292c0d072b99d (
plain) (
blame)
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
|
#!/bin/bash
set -ex
EXTERNAL="$(xrandr | grep 'DisplayPort.* connected' | cut -d' ' -f1)"
map_wacom () {
xsetwacom set 'Wacom Intuos S Pen stylus' MapToOutput $1 2>/dev/null || true
}
if [ -z "$EXTERNAL" ]; then
# No external display; only use laptop screen
xrandr --output eDP --primary --auto --output $EXTERNAL --off
map_wacom eDP
else
# External display; check if it is currently used
set +e
xrandr --listactivemonitors | grep $EXTERNAL >/dev/null
RESULT=$?
set -e
if [ $RESULT -eq 0 ]; then
# External display in use; disable
xrandr --output eDP --primary --auto --output $EXTERNAL --off
map_wacom eDP
else
# External display not in use; enable
xrandr --output eDP --auto --below $EXTERNAL --primary --output $EXTERNAL --auto
map_wacom $EXTERNAL
fi
fi
# Reset background
setbg
|