Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Root?
- if [ "$(id -u)" != "0" ]; then
- exec sudo "$0" "$@"
- fi
- fan_speeds()
- {
- echo "Available fan speeds on this iMac:"
- echo "1) Fan speed: $one_min - $one_max"
- echo "2) Fan speed: $two_min - $two_max"
- echo "3) Fan speed: $three_min - $three_max"
- }
- fan_manual()
- {
- echo 1 > /sys/devices/platform/applesmc.768/fan1_manual
- echo 1 > /sys/devices/platform/applesmc.768/fan2_manual
- echo 1 > /sys/devices/platform/applesmc.768/fan3_manual
- }
- fan1_speed()
- {
- echo $1 > /sys/devices/platform/applesmc.768/fan1_output
- }
- fan2_speed()
- {
- echo $1 > /sys/devices/platform/applesmc.768/fan2_output
- }
- fan3_speed()
- {
- echo $1 > /sys/devices/platform/applesmc.768/fan3_output
- }
- # Variables
- one_min=$(cat /sys/devices/platform/applesmc.768/fan1_min)
- one_max=$(cat /sys/devices/platform/applesmc.768/fan1_max)
- two_min=$(cat /sys/devices/platform/applesmc.768/fan2_min)
- two_max=$(cat /sys/devices/platform/applesmc.768/fan2_max)
- three_min=$(cat /sys/devices/platform/applesmc.768/fan3_min)
- three_max=$(cat /sys/devices/platform/applesmc.768/fan3_max)
- # Main
- if [ $# = 0 ]
- then
- echo "Define Speed"
- fan_speeds
- elif [ $# = 1 ]
- then
- fan_manual
- fan1_speed $1
- fan2_speed $1
- fan3_speed $1
- elif [ $# = 2 ]
- then
- echo "Define 3 Speeds"
- elif [ $# = 3 ]
- then
- fan_manual
- fan1_speed $1
- fan2_speed $2
- fan3_speed $3
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement