diff --git a/README.md b/README.md index 00e315d..6429a3e 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ Repository with various scripts/configs for Arch Linux on the Lenovo Legion 7 (2 Scripts in the `bin` folder should be placed in `/usr/local/bin` or a similar directory and given execute permissions. -- `brightness_up` and `brightness_down`: See which GPU is connected and control brightness using ACPI -- `conservation_mode`: Toggle battery conservation mode which limits charge to 60% to preserve its health -- `power_saving_mode`: Change CPU governor, brightness, and refresh rate to extend battery life +- `brightness-up` and `brightness-down`: See which GPU is connected and control brightness using ACPI +- `conservation-mode`: Toggle battery conservation mode which limits charge to 60% to preserve its health +- `power-saving-mode`: Change CPU governor, brightness, and refresh rate to extend battery life Files in the `modprobe.d` folder should be placed in `/etc/modprobe.d` and owned by `root`. diff --git a/bin/brightness_down b/bin/brightness-down similarity index 100% rename from bin/brightness_down rename to bin/brightness-down diff --git a/bin/brightness_up b/bin/brightness-up similarity index 100% rename from bin/brightness_up rename to bin/brightness-up diff --git a/bin/conservation_mode b/bin/conservation-mode similarity index 100% rename from bin/conservation_mode rename to bin/conservation-mode diff --git a/bin/power_saving_mode b/bin/power-saving-mode similarity index 73% rename from bin/power_saving_mode rename to bin/power-saving-mode index 5361271..ed145e2 100644 --- a/bin/power_saving_mode +++ b/bin/power-saving-mode @@ -3,42 +3,40 @@ # Run as sudo [ "$UID" -eq 0 ] || exec sudo -E "$0" "$@" -if grep -q powersave "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"; -then +STATE_FILE="/tmp/power_saving_mode" +[ -f "$STATE_FILE" ] && STATE=$(cat "$STATE_FILE") || STATE="performance" + +if [ "$STATE" == "powersave" ]; then # Set CPU scaling governor - for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; - do - echo "schedutil" > $file; - done + 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 i in {1..4}; do brightness_up; done + 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 - for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; - do - echo "powersave" > $file; - done + 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 i in {1..4}; do brightness_down; done + 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