Advertisement
TheAtomicAss

pg279q-rate-switch.sh

Apr 10th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. #!/bin/bash
  2. set -x
  3. DISPLAY=:0.0
  4.  
  5. # v 1.0
  6.  
  7. # This script switches the refresh rate on the PG279Q monitor, from 60 (referenced as 59.95) and 165
  8. # This is done because Nvidia likes to bump up the clock speed when running at the higher rate, even when idle
  9.  
  10. toggle()
  11. (
  12. if [[ $(xrandr|awk '/2560x1440/{while (!match ($0,"59.95*+")) getline; print $2; exit;}') == "59.95*+" ]]
  13. then
  14. xrandr --output DP-0 --mode 2560x1440 --rate 165
  15. notify-send "PG279Q" "Monitor is now set to 165 hz"
  16. else
  17. xrandr --output DP-0 --mode 2560x1440 --rate 60
  18. notify-send "PG279Q" "Monitor is now set to 60 hz"
  19. fi
  20. )
  21.  
  22. drop()
  23. (
  24. if [[ $(xprintidle) -gt 900000 && $(xrandr|awk '/2560x1440/{while (!match ($0,"59.95*+")) getline; print $2; exit;}') != "59.95*+" ]]
  25. then
  26. xrandr --output DP-0 --mode 2560x1440 --rate 60
  27. notify-send "PG279Q" "Monitor was automatically set to 60hz due to user inactivity"
  28. fi
  29. )
  30.  
  31. case $1 in
  32. toggle)toggle;;
  33. drop)drop;;
  34. *)echo "No valid command specified";
  35. notify-send "PG279Q: Error" "No valid command specified";;
  36. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement