-
Notifications
You must be signed in to change notification settings - Fork 0
/
fans
32 lines (24 loc) · 1 KB
/
fans
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
#!/usr/bin/env python
import argparse
import traceback
from hardware_control.fan_control import set_fan_speed
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Manually control fan speed. Minimum speed is 10%.")
parser.add_argument("speed", nargs='?', help="Fan speed to set, from 0.1 to 1, or 'off' to disable.")
parser.add_argument("-v", "--verbose", help="Print full exception stack trace.", action='store_true')
args = parser.parse_args()
try:
if args.speed == "off":
print("Turned off fans")
set_fan_speed(0)
elif args.speed:
target = float(args.speed)
if target < 0.1 or target > 1:
print("Speed setting has to either 0 or between 0.1 and 1")
else:
print("Set fan speed to {0}%".format(str(target * 100)))
set_fan_speed(target)
except Exception as e:
print("Error:", str(e))
if args.verbose:
traceback.print_exc()