Created
November 21, 2019 22:24
-
-
Save ToxicFrog/f03f4c4387050ded7c30e72dbbe8b7fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Simple script to toggle fan speed for thinkpad laptops from auto to | |
# full-speed. Need sudo or custom group made to access /proc/acpi. | |
# Also needs fan_control=1 in thinkpad_acpi kmod options. | |
# Automatically abort on error. | |
set -e | |
# Read current fan speed. Made constant (declare -r) since it won't be changed | |
# after initialization. | |
declare -r cur_speed="$(cat /proc/acpi/ibm/fan | egrep -i "^level:" | awk '{print $2}')" | |
if [[ "$cur_speed" == "auto" ]]; then | |
# No block scope in bash, so we can declare swap_speed in here, making it a | |
# bit clearer what the possible values are. | |
swap_speed="full-speed"; | |
else | |
swap_speed="auto" | |
fi | |
# If this fails, set -e will abort the script before we get to notify-send. | |
echo "level $swap_speed" | sudo tee /proc/acpi/ibm/fan | |
notify-send "Changed fan speed to $swap_speed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment