TheAtomicAss icon

pg279q-rate-switch.sh

TheAtomicAss | PRO | 04/10/16 08:31:18 AM UTC | 0 ⭐ | 391 👁️ | Never ⏰ | []
text |

1.11 KB

|

None

|

0 👍

/

0 👎

#!/bin/bash
set -x
DISPLAY=:0.0
 # v 1.0
 # This script switches the refresh rate on the PG279Q monitor, from 60 (referenced as 59.95) and 165
# This is done because Nvidia likes to bump up the clock speed when running at the higher rate, even when idle
 toggle()
(
  if [[ $(xrandr|awk '/2560x1440/{while (!match ($0,"59.95*+")) getline; print $2; exit;}') == "59.95*+" ]]
    then
      xrandr --output DP-0 --mode 2560x1440 --rate 165
      notify-send "PG279Q" "Monitor is now set to 165 hz"
    else
      xrandr --output DP-0 --mode 2560x1440 --rate 60
      notify-send "PG279Q" "Monitor is now set to 60 hz"
  fi
)
 drop()
(
  if [[ $(xprintidle) -gt 900000 && $(xrandr|awk '/2560x1440/{while (!match ($0,"59.95*+")) getline; print $2; exit;}') != "59.95*+" ]]
    then
      xrandr --output DP-0 --mode 2560x1440 --rate 60
      notify-send "PG279Q" "Monitor was automatically set to 60hz due to user inactivity"
  fi
)
 case $1 in
    toggle)toggle;;
      drop)drop;;
         *)echo "No valid command specified";
           notify-send "PG279Q: Error" "No valid command specified";;
esac

Comments