Advertisement
Guest User

Untitled

a guest
Sep 25th, 2014
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #!/bin/bash
  2. DISPLAY=:0.0
  3.  
  4. HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
  5.  
  6. sudo touch /home/arayray/Desktop/test.txt
  7. #sudo touch /home/arayray/Desktop/error.txt
  8.  
  9. if [ "${HDMI_STATUS}" = connected ]; then
  10. sudo -u "$USER" echo "SCRIPT CONNECTED STARTED" | sudo tee -a /home/arayray/Desktop/test.txt
  11. #sleep 5
  12. sudo -u "$USER" echo "HDMI CONNECTED" | sudo tee -a /home/arayray/Desktop/test.txt
  13. # Send notification
  14. sudo -u "$USER" notify-send -i display "HDMI CONNECTED" -t 60000
  15.  
  16. # Set the sound card profile
  17. sudo -u "$USER" pactl set-card-profile 0 output:hdmi-stereo
  18. if [ $? -eq 0 ]; then
  19. sudo -u "$USER" echo "COMMAND SUCCESFUL" | sudo tee -a /home/arayray/Desktop/test.txt
  20. else
  21. sudo -u "$USER" echo "COMMAND FAILED" | sudo tee -a /home/arayray/Desktop/test.txt
  22. fi
  23. sudo -u "$USER" echo "SCRIPT CONNECTED COMPLETED" | sudo tee -a /home/arayray/Desktop/test.txt
  24. else
  25. sudo -u "$USER" echo "SCRIPT DISCONNECTED STARTED" | sudo tee -a /home/arayray/Desktop/test.txt
  26. #sleep 5
  27. sudo -u "$USER" echo "HDMI DISCONNECTED" | sudo tee -a /home/arayray/Desktop/test.txt
  28. # Send notification
  29. sudo -u "$USER" notify-send -i display "HDMI DISCONNECTED" -t 60000
  30.  
  31. # Set the sound card profile
  32. sudo -u "$USER" pactl set-card-profile 0 output:analog-stereo
  33. sudo -u "$USER" echo "SCRIPT DISCONNECTED COMPLETED" | sudo tee -a /home/arayray/Desktop/test.txt
  34. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement