when turning off displays, turn of the disconnected too

This commit is contained in:
2018-09-12 14:12:23 +03:00
parent 35b5ec0e44
commit 6693de67ec

View File

@@ -19,6 +19,13 @@ WORKSTATIONLEFT=$MAIN
WORKSTATIONRIGHT=$DIGITAL
'
_allon() {
_list_connected | while read display; do
_xrandr --output $display --auto
done
exit
}
_display_main() {
[[ -f "$CONFIG" ]] || {
echo "ERROR: You do not have configuration yet"
@@ -29,7 +36,7 @@ _display_main() {
_allon
}
_xrandr --output "$MAIN" --auto --gamma $g:$g:$g
xrandr | grep " connected" | awk '{ print $1 }' | grep -v "$MAIN" | while read display; do
_list_all | grep -v "$MAIN" | while read display; do
_xrandr --output $display --off
done
@@ -40,7 +47,7 @@ _display_presentation() {
echo "Display MAIN=$MAIN is not connected, trying to turn all on. Please check your setup: $CONFIG"
_allon
}
xrandr | grep " connected" | awk '{ print $1 }' | while read display; do
_list_connected | while read display; do
_xrandr --output $display --mode 1024x768 --pos 0x0 --gamma $g:$g:$g
done
}
@@ -60,7 +67,7 @@ _display_workstation() {
if [ -z "$WORKSTATIONRIGHT" ];then
# Single display setup
_xrandr --output "$WORKSTATIONLEFT" --auto --gamma $g:$g:$g
xrandr | grep " connected" | awk '{ print $1 }' | grep -v "$WORKSTATIONLEFT" | while read display; do
_list_all | grep -v "$WORKSTATIONLEFT" | while read display; do
_xrandr --output $display --off
done
return
@@ -71,7 +78,7 @@ _display_workstation() {
_allon
}
_xrandr --output "$WORKSTATIONLEFT" --auto --gamma $g:$g:$g --output "$WORKSTATIONRIGHT" --auto --gamma $g:$g:$g --right-of "$WORKSTATIONLEFT"
xrandr | grep " connected" | awk '{ print $1 }' | grep -v "$WORKSTATIONLEFT" | grep -v "$WORKSTATIONRIGHT" | while read display; do
_list_all | grep -v "$WORKSTATIONLEFT" | grep -v "$WORKSTATIONRIGHT" | while read display; do
_xrandr --output $display --off
done
@@ -79,11 +86,11 @@ _display_workstation() {
_isconnected() {
xrandr | grep -q "${1} connected"
}
_allon() {
xrandr | grep " connected" | awk '{ print $1 }' | while read display; do
_xrandr --output $display --auto
done
exit
_list_all() {
xrandr | grep -e " connected" -e " disconnected" | awk '{ print $1 }'
}
_list_connected() {
xrandr | grep -e " connected" | awk '{ print $1 }'
}
_setup() {
@@ -95,7 +102,7 @@ _setup() {
xrandr | grep connected | awk '{ print "#"$1": "$2 }'
echo "$TEMPLATE"
} > "$CONFIG"
FIRST=$( xrandr | grep connected | head -n1 | awk '{ print $1 }' )
FIRST=$( _list_all | head -n1 )
sed -i 's,^MAIN=.*,MAIN='$FIRST',' "$CONFIG"
}
echo '# Current configuration:'