-
Notifications
You must be signed in to change notification settings - Fork 0
/
dell_fans.sh
executable file
·48 lines (43 loc) · 1.38 KB
/
dell_fans.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
########################################################################
###### Custom script to control my Dell XPS 9700 fans... ######
## Make sure there is a file in /etc/sudoers.d/ so that you can
## run this script without sudo. Execute the following:
##
## echo "entreri ALL=(ALL) NOPASSWD: /usr/bin/dell-bios-fan-control, /usr/bin/i8kctl" > /etc/sudoers.d/entreri-fan_control
## sudo chmod 0440 /etc/sudoers.d/entreri-fan_control
##
## Then add an alias for this script to ~/.bashrc: alias fans="~/.local/bin/entreri-fans.sh"
########################################################################
echo "Usage: [low|high] will set fan speed manually. [auto] will turn on automatic bios fan control. No arugment will show current fan status."
# # Check if there is exactly one argument provided
# if [ "$#" -ne 1 ]; then
# echo "Usage: $0 [reset|low|high]"
# exit 1
# fi
# Show current fan status
if [ "$#" -ne 1 ]; then
echo "Checking current fan status..."
i8kctl
exit 0
fi
case $1 in
low)
echo "Setting fan speed to low..."
sudo dell-bios-fan-control 0
sudo i8kctl fan 1 1
;;
high)
echo "Setting fan speed to high..."
sudo dell-bios-fan-control 0
sudo i8kctl fan 2 2
;;
reset | bios | auto)
echo "Resetting fan control to BIOS control..."
sudo dell-bios-fan-control 1
;;
*)
echo "Error: Invalid argument. Use 'auto', 'low', or 'high'."
exit 2
;;
esac