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