Skip to content

Instantly share code, notes, and snippets.

@sysrq-reisub
Forked from chrp/fanny.rb
Last active February 16, 2016 20:45
Show Gist options
  • Save sysrq-reisub/90f204ada41831e49e7d to your computer and use it in GitHub Desktop.
Save sysrq-reisub/90f204ada41831e49e7d to your computer and use it in GitHub Desktop.
Auto adjust fan speed of graphics card with ATI catalyst driver on Ubuntu.
#!/usr/bin/env ruby
# encoding: utf-8
# first part, get temperature
temp_str = `aticonfig --adapter=0 --od-gettemperature`
temp = temp_str.scan(/Sensor 0: Temperature - (\d+\.\d+) C/)[0][0].to_i
# determine fan speed
thresholds = [ 40, 60, 70, 80, 85 ]
speeds = [ 30, 45, 50, 65, 70 ]
speed = 100 # default speed
thresholds.each_with_index do |threshold, index|
speed = speeds[index] and break if temp < threshold
end
# set speed
`aticonfig --pplib-cmd "set fanspeed 0 #{speed}"`
puts "Temperature: #{temp}°C / Fan speed level: #{speed}%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment