add hdmi_toggle.sh - simple udev hook to configure hdmi display
This commit is contained in:
23
hdmi_toggle.sh
Normal file
23
hdmi_toggle.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
|
||||
# grab the display and xauthority cookie
|
||||
export DISPLAY=$(w -h -s | grep ":[0-9]\W" | head -1 | awk '{print $2}')
|
||||
X_USER=$(w -h -s | grep ":[0-9]\W" | head -1 | awk '{print $1}')
|
||||
export XAUTHORITY=/home/$X_USER/.Xauthority
|
||||
|
||||
# get the status of the external display
|
||||
status=$(< /sys/class/drm/card0-HDMI-A-1/status)
|
||||
case $status in
|
||||
disconnected)
|
||||
su $X_USER -c 'xrandr --output HDMI-1 --off'
|
||||
logger "disabled hdmi output for $X_USER"
|
||||
;;
|
||||
connected)
|
||||
while [[ $(< /sys/class/drm/card0-HDMI-A-1/enbled) ne 'enabled' ]]; do
|
||||
su $X_USER -c 'xrandr --output HDMI-1 --auto'
|
||||
sleep 1;
|
||||
done
|
||||
su $X_USER -c 'xrandr --output HDMI-1 --auto --right-of eDP-1'
|
||||
logger "enabled hdmi output for $X_USER"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user