Skip to content

Instantly share code, notes, and snippets.

@atotto
Last active May 26, 2017 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atotto/5c1d55a2cb99ced9f7c7 to your computer and use it in GitHub Desktop.
Save atotto/5c1d55a2cb99ced9f7c7 to your computer and use it in GitHub Desktop.
fan control using hub-ctrl
#!/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