Created
January 31, 2022 19:33
-
-
Save coenraadhuman/06b91ad3b24c963b4a8160d2f2bcf7ae to your computer and use it in GitHub Desktop.
Dell G5 15 - Fan Control Ubuntu
This file contains hidden or 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 | |
set -euo pipefail | |
function main() { | |
must_root | |
sudo apt install i8kutils | |
sudo snap install dell-bios-fan-control | |
sudo snap connect dell-bios-fan-control:io-ports-control | |
} | |
function must_root() { | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
} | |
main $@ |
This file contains hidden or 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 | |
set -euo pipefail | |
function main() { | |
if [[ $# -eq 0 ]] || [[ $# -eq 1 ]]; then | |
echo "Not all mandatory options are supplied, please supply an option for both fans." | |
print_options | |
exit 1 | |
fi | |
must_root | |
modprobe i8k force=1 | |
dell-bios-fan-control 0 | |
echo "Options selected: fan 1 = "$1", fan 2 = "$2"." | |
check_option $1 | |
check_option $2 | |
echo "Previous options selected:" | |
i8kctl fan $1 $2 | |
} | |
function must_root() { | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
} | |
function check_option() { | |
if [[ "$1" = "0" ]] || [[ "$1" = "1" ]] || [[ "$1" = "2" ]] || [[ "$1" = "-" ]]; then | |
echo "Option "$1" is valid." | |
else | |
echo "Option "$1" is invalid." | |
print_options | |
exit 1 | |
fi | |
} | |
function print_options() { | |
echo "Please select from the following options:" | |
echo "0 turn the fan off" | |
echo "1 set low speed" | |
echo "2 set high speed" | |
echo "- don't change the state of this fan" | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment