Skip to content

Instantly share code, notes, and snippets.

@chrp
Created August 12, 2013 15:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrp/6211802 to your computer and use it in GitHub Desktop.
Save chrp/6211802 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 = [ 10, 25, 30, 35, 50 ]
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