-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonitor-hotplug.sh
executable file
·46 lines (38 loc) · 1.33 KB
/
monitor-hotplug.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
#export PATH=/usr/bin
#
#USER_NAME=$(who | awk -v vt=tty$(fgconsole) '$0 ~ vt {print $1}')
#USER_ID=$(id -u "$USER_NAME")
#CARD_PATH="/sys/class/drm/card0/"
#AUDIO_OUTPUT="analog-stereo"
#PULSE_SERVER="unix:/run/user/"$USER_ID"/pulse/native"
export XAUTHORITY=/home/collin/.Xauthority
export DISPLAY=:0
touch /root/it-ran
# Get out of town if something errors
set -e
HDMI_STATUS=$(/bin/cat /sys/class/drm/card0/card0-HDMI-A-1/status)
if [[ "$HDMI_STATUS" == "connected" ]]; then
/usr/bin/xrandr --output HDMI1 --auto --left-of eDP1
/usr/bin/notify-send --urgency=normal -t 5000 "Graphics Update" "HDMI plugged in"
else
/usr/bin/xrandr --output HDMI1 --off
/usr/bin/notify-send --urgency=normal -t 5000 "Graphics Update" "External monitor disconnected"
fi
#for OUTPUT in $(cd "$CARD_PATH" && echo card*); do
# OUT_STATUS=$(<"$CARD_PATH"/"$OUTPUT"/status)
# if [[ $OUT_STATUS == connected ]]
# then
# echo $OUTPUT connected
# case "$OUTPUT" in
# "card0-HDMI-A-1")
# AUDIO_OUTPUT="hdmi-stereo" # Digital Stereo (HDMI 1)
# ;;
# "card0-HDMI-A-2")
# AUDIO_OUTPUT="hdmi-stereo-extra1" # Digital Stereo (HDMI 2)
# ;;
# esac
# fi
#done
#echo selecting output $AUDIO_OUTPUT
#sudo -u "$USER_NAME" pactl --server "$PULSE_SERVER" set-card-profile 0 output:$AUDIO_OUTPUT+input:analog-stereo