Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- DISPLAY=:0.0
- HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
- sudo touch /home/arayray/Desktop/test.txt
- #sudo touch /home/arayray/Desktop/error.txt
- if [ "${HDMI_STATUS}" = connected ]; then
- sudo -u "$USER" echo "SCRIPT CONNECTED STARTED" | sudo tee -a /home/arayray/Desktop/test.txt
- #sleep 5
- sudo -u "$USER" echo "HDMI CONNECTED" | sudo tee -a /home/arayray/Desktop/test.txt
- # Send notification
- sudo -u "$USER" notify-send -i display "HDMI CONNECTED" -t 60000
- # Set the sound card profile
- sudo -u "$USER" pactl set-card-profile 0 output:hdmi-stereo
- if [ $? -eq 0 ]; then
- sudo -u "$USER" echo "COMMAND SUCCESFUL" | sudo tee -a /home/arayray/Desktop/test.txt
- else
- sudo -u "$USER" echo "COMMAND FAILED" | sudo tee -a /home/arayray/Desktop/test.txt
- fi
- sudo -u "$USER" echo "SCRIPT CONNECTED COMPLETED" | sudo tee -a /home/arayray/Desktop/test.txt
- else
- sudo -u "$USER" echo "SCRIPT DISCONNECTED STARTED" | sudo tee -a /home/arayray/Desktop/test.txt
- #sleep 5
- sudo -u "$USER" echo "HDMI DISCONNECTED" | sudo tee -a /home/arayray/Desktop/test.txt
- # Send notification
- sudo -u "$USER" notify-send -i display "HDMI DISCONNECTED" -t 60000
- # Set the sound card profile
- sudo -u "$USER" pactl set-card-profile 0 output:analog-stereo
- sudo -u "$USER" echo "SCRIPT DISCONNECTED COMPLETED" | sudo tee -a /home/arayray/Desktop/test.txt
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement