Merge commit 'd1e8697ba619ce14cbc0580da0d607e5ccff8c72'
This commit is contained in:
@@ -11,6 +11,9 @@ HDMI_STATUS=$(</sys/class/drm/card0/card0-HDMI-A-1/status )
|
||||
|
||||
HDMI_ENABLED=$(</sys/class/drm/card0/card0-HDMI-A-1/enabled)
|
||||
|
||||
DP_STATUS=$(</sys/class/drm/card0/card0-DP-1/status )
|
||||
DP_ENABLED=$(</sys/class/drm/card0/card0-DP-1/enabled )
|
||||
|
||||
# Check to see if our state log exists
|
||||
if [ ! -f /tmp/monitor ]; then
|
||||
touch /tmp/monitor
|
||||
@@ -22,15 +25,41 @@ fi
|
||||
# The state log has the NEXT state to go to in it
|
||||
|
||||
# If monitors are disconnected, stay in state 1
|
||||
if [ "disconnected" == "$HDMI_STATUS" -a "disconnected" == "$VGA_STATUS" ]; then
|
||||
STATE=1
|
||||
if [ "disconnected" == "$HDMI_STATUS" -a "disconnected" == "$DP_STATUS" ]; then
|
||||
STATE=5
|
||||
fi
|
||||
|
||||
if [ $1 == "mirror" ]; then
|
||||
if [ $STATE == 4 ]; then
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Mirror Stuff from $STATE to 5"
|
||||
# eDP-1 is on, projectors are mirroring
|
||||
if [ "connected" == "$HDMI_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto --same-as eDP-1
|
||||
TYPE="HDMI"
|
||||
elif [ "connected" == "$DP_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --off --output DP-1 --auto --same-as eDP-1
|
||||
TYPE="DP-1"
|
||||
fi
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE mirroring"
|
||||
STATE=5
|
||||
else
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Mirror Stuff from $STATE to 4"
|
||||
# eDP-1 is on, projectors are extending
|
||||
if [ "connected" == "$HDMI_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto --right-of eDP-1
|
||||
TYPE="HDMI"
|
||||
elif [ "connected" == "$DP_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --off --output DP-1 --auto --left-of eDP-1
|
||||
TYPE="DP-1"
|
||||
fi
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE extending"
|
||||
STATE=4
|
||||
fi
|
||||
else
|
||||
TYPE="eDP-1"
|
||||
case $STATE in
|
||||
1)
|
||||
# eDP-1 is on, projectors not connected
|
||||
/usr/bin/xrandr --output eDP-1 --auto
|
||||
TYPE="eDP-1"
|
||||
STATE=2
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE"
|
||||
;;
|
||||
@@ -46,6 +75,9 @@ case $STATE in
|
||||
if [ "connected" == "$HDMI_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --off --output HDMI-1 --auto
|
||||
TYPE="HDMI"
|
||||
elif [ "connected" == "$DP_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --off --output HDMI-1 --off --output DP-1 --auto
|
||||
TYPE="DP-1"
|
||||
fi
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE"
|
||||
STATE=4
|
||||
@@ -53,8 +85,11 @@ case $STATE in
|
||||
4)
|
||||
# eDP-1 is on, projectors are mirroring
|
||||
if [ "connected" == "$HDMI_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto --same-as eDP-1
|
||||
TYPE="HDMI"
|
||||
elif [ "connected" == "$DP_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --off --output DP-1 --auto --same-as eDP-1
|
||||
TYPE="DP-1"
|
||||
fi
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE mirroring"
|
||||
STATE=5
|
||||
@@ -64,6 +99,9 @@ case $STATE in
|
||||
if [ "connected" == "$HDMI_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto --right-of eDP-1
|
||||
TYPE="HDMI"
|
||||
elif [ "connected" == "$DP_STATUS" ]; then
|
||||
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --off --output DP-1 --auto --left-of eDP-1
|
||||
TYPE="DP-1"
|
||||
fi
|
||||
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE extending"
|
||||
STATE=2
|
||||
@@ -72,5 +110,6 @@ case $STATE in
|
||||
# Unknown state, assume we're in 1
|
||||
STATE=1
|
||||
esac
|
||||
fi
|
||||
|
||||
echo $STATE > /tmp/monitor
|
||||
|
||||
Reference in New Issue
Block a user