43 lines
1.5 KiB
Bash
43 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
# Run as sudo
|
|
[ "$UID" -eq 0 ] || exec sudo -E "$0" "$@"
|
|
|
|
STATE_FILE="/tmp/power_saving_mode"
|
|
[ -f "$STATE_FILE" ] && STATE=$(cat "$STATE_FILE") || STATE="performance"
|
|
|
|
if [ "$STATE" == "powersave" ]; then
|
|
# Set CPU scaling governor
|
|
cpupower frequency-set -g performance
|
|
# Set refresh rate
|
|
xrandr --output DP-4 --mode 2560x1600 --rate 165 > /dev/null 2>&1
|
|
xrandr --output eDP --mode 2560x1600 --rate 165 > /dev/null 2>&1
|
|
xrandr --output eDP-1 --mode 2560x1600 --rate 165 > /dev/null 2>&1
|
|
# Set brightness
|
|
for _ in {1..4}; do brightness-up; done
|
|
# Restart compositor
|
|
pkill picom
|
|
picom -b
|
|
# Done
|
|
echo "Power Saving Mode is now inactive"
|
|
echo "performance" > "$STATE_FILE"
|
|
sudo -u nick DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "Power Saving Mode is now inactive"
|
|
else
|
|
# Set CPU scaling governor
|
|
cpupower frequency-set -g powersave
|
|
# Set refresh rate
|
|
xrandr --output DP-4 --mode 2560x1600 --rate 60 > /dev/null 2>&1
|
|
xrandr --output eDP --mode 2560x1600 --rate 60 > /dev/null 2>&1
|
|
xrandr --output eDP-1 --mode 2560x1600 --rate 60 > /dev/null 2>&1
|
|
# Set brightness
|
|
for _ in {1..4}; do brightness-down; done
|
|
# Kill music visualizer
|
|
pkill glava
|
|
# Kill compositor
|
|
pkill picom
|
|
# Done
|
|
echo "Power Saving Mode is now active"
|
|
echo "powersave" > "$STATE_FILE"
|
|
sudo -u nick DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus notify-send "Power Saving Mode is now active"
|
|
fi
|