#!/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