/
xdisplay
executable file
·37 lines (30 loc) · 937 Bytes
/
xdisplay
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
#!/bin/bash
#
# This script toggles the extended monitor outputs if something is connected
#
DISPLAY=:0.0
export DISPLAY
# your notebook monitor
DEFAULT_OUTPUT='LVDS1'
# outputs to toggle if connected
OUTPUTS='VGA1 HDMI1'
# get info from xrandr
XRANDR=`xrandr`
EXECUTE=""
for CURRENT in $OUTPUTS
do
if [[ $XRANDR == *$CURRENT\ connected* ]] # is connected
then
if [[ $XRANDR == *$CURRENT\ connected\ \(* ]] # is disabled
then
EXECUTE+="--output $CURRENT --auto --right-of $DEFAULT_OUTPUT "
else
EXECUTE+="--output $CURRENT --off "
fi
else # make sure disconnected outputs are off
EXECUTE+="--output $CURRENT --off "
fi
done
xrandr --output $DEFAULT_OUTPUT --auto $EXECUTE
xset -b
#xrandr --output HDMI1 --auto --output VGA1 --auto --right-of HDMI1 --output LVDS1 --off