Last active
May 26, 2017 00:24
-
-
Save atotto/5c1d55a2cb99ced9f7c7 to your computer and use it in GitHub Desktop.
fan control using hub-ctrl
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
#!/bin/sh | |
# $ wget http://www.gniibe.org/oitoite/ac-power-control-by-USB-hub/hub-ctrl.c | |
# $ gcc -O2 -o hub-ctrl hub-ctrl.c -lusb | |
# $ sudo chown root:$USER hub-ctrl | |
# $ sudo chmod +s hub-ctrl | |
# $ mv hub-ctrl ~/bin | |
usage() { | |
echo "Usage: $0 (on|off)" | |
exit 2; | |
} | |
if [ $# -ne 1 ]; then | |
usage | |
fi | |
fanctrl() { | |
power=$1 | |
device=0409:005a | |
args=$(lsusb -d $device | grep -Po '\d+' | paste -sd ' ' | cut -d ' ' -f 1,2 | xargs printf "-b %s -d %s") | |
~/bin/hub-ctrl $args -P 1 -p $power | |
} | |
case $1 in | |
on ) fanctrl 1;; | |
off ) fanctrl 0;; | |
* ) usage | |
exit 2;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment