Create a gist now

Instantly share code, notes, and snippets.

@atotto /fan-ctrl.sh
Last active May 26, 2017

What would you like to do?
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