Squashed 'i3/' changes from dd4b0c9..3b59540

3b59540 Some cleanup, more monitor stuff
2a7e4c5 Add monitor setup

git-subtree-dir: i3
git-subtree-split: 3b59540cda64e740d296c3c2928d7e5696304bbd
This commit is contained in:
murgi
2017-05-24 17:39:04 +02:00
parent 13ace96ffd
commit 1d94a73b6f
6 changed files with 154 additions and 46 deletions

76
switch_monitors.sh Executable file
View File

@@ -0,0 +1,76 @@
#! /bin/sh
#
# switch_monitors.sh
# Copyright (C) 2017 Fabian Ising <fabian@murgi.de>
#
# Distributed under terms of the Apache v2.0 license.
#
# Get info on the monitors
HDMI_STATUS=$(</sys/class/drm/card0/card0-HDMI-A-1/status )
HDMI_ENABLED=$(</sys/class/drm/card0/card0-HDMI-A-1/enabled)
# Check to see if our state log exists
if [ ! -f /tmp/monitor ]; then
touch /tmp/monitor
STATE=5
else
STATE=$(</tmp/monitor)
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
fi
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"
;;
2)
# eDP-1 is on, projectors are connected but inactive
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --off
TYPE="eDP-1"
STATE=3
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE"
;;
3)
# eDP-1 is off, projectors are on
if [ "connected" == "$HDMI_STATUS" ]; then
/usr/bin/xrandr --output eDP-1 --off --output HDMI-1 --auto
TYPE="HDMI"
fi
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE"
STATE=4
;;
4)
# eDP-1 is on, projectors are mirroring
if [ "connected" == "$HDMI_STATUS" ]; then
/usr/bin/xrandr --output eDP-1 --auto --output HDMI-1 --auto
TYPE="HDMI"
fi
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE mirroring"
STATE=5
;;
5)
# 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"
fi
/usr/bin/notify-send -t 5000 --urgency=low "Graphics Update" "Switched to $TYPE extending"
STATE=2
;;
*)
# Unknown state, assume we're in 1
STATE=1
esac
echo $STATE > /tmp/monitor