Created
January 3, 2019 16:14
-
-
Save michaelneu/2161b8c4b9febe3720cdd6ddad6cfd14 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/python2 | |
def set_speed(pwm, speed): | |
speed = max(0, min(100, speed)) | |
speed = 2.55 * speed | |
speed = int(speed) | |
with open("/sys/class/hwmon/hwmon1/pwm" + str(pwm), "w") as f: | |
f.write(str(speed)) | |
import sys | |
import os | |
if len(sys.argv) == 2: | |
sys.argv.append(sys.argv[1]) | |
if len(sys.argv) == 3: | |
if os.geteuid() != 0: | |
os.system("sudo " + " ".join(sys.argv)) | |
else: | |
set_speed(2, int(sys.argv[1])) | |
set_speed(3, int(sys.argv[1])) | |
else: | |
print "fanspeed fan1 [fan2]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment