Advertisement
Guest User

Untitled

a guest
Mar 9th, 2025
105
0
270 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Root?
  4. if [ "$(id -u)" != "0" ]; then
  5.   exec sudo "$0" "$@"
  6. fi
  7.  
  8. fan_speeds()
  9. {
  10.   echo "Available fan speeds on this iMac:"
  11.   echo "1) Fan speed: $one_min - $one_max"
  12.   echo "2) Fan speed: $two_min - $two_max"
  13.   echo "3) Fan speed: $three_min - $three_max"
  14. }
  15.  
  16. fan_manual()
  17. {
  18.   echo 1 > /sys/devices/platform/applesmc.768/fan1_manual
  19.   echo 1 > /sys/devices/platform/applesmc.768/fan2_manual
  20.   echo 1 > /sys/devices/platform/applesmc.768/fan3_manual
  21. }
  22.  
  23. fan1_speed()
  24. {
  25.   echo $1 > /sys/devices/platform/applesmc.768/fan1_output
  26. }
  27.  
  28. fan2_speed()
  29. {
  30.   echo $1 > /sys/devices/platform/applesmc.768/fan2_output
  31. }
  32.  
  33. fan3_speed()
  34. {
  35.   echo $1 > /sys/devices/platform/applesmc.768/fan3_output
  36. }
  37.  
  38. # Variables
  39. one_min=$(cat /sys/devices/platform/applesmc.768/fan1_min)
  40. one_max=$(cat /sys/devices/platform/applesmc.768/fan1_max)
  41. two_min=$(cat /sys/devices/platform/applesmc.768/fan2_min)
  42. two_max=$(cat /sys/devices/platform/applesmc.768/fan2_max)
  43. three_min=$(cat /sys/devices/platform/applesmc.768/fan3_min)
  44. three_max=$(cat /sys/devices/platform/applesmc.768/fan3_max)
  45.  
  46. # Main
  47. if [ $# = 0 ]
  48. then
  49.   echo "Define Speed"
  50.   fan_speeds
  51. elif [ $# = 1 ]
  52. then
  53.    fan_manual
  54.    fan1_speed $1
  55.    fan2_speed $1
  56.    fan3_speed $1
  57. elif [ $# = 2 ]
  58. then
  59.   echo "Define 3 Speeds"
  60. elif [ $# = 3 ]
  61. then
  62.   fan_manual
  63.   fan1_speed $1
  64.   fan2_speed $2
  65.   fan3_speed $3
  66. fi
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement