Created
August 2, 2018 12:46
-
-
Save ipepe/5cdaef0c7d598e172d9e98c5f095304b to your computer and use it in GitHub Desktop.
Cool but louder custom smc-controlled bitBar script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env /Users/pptasinski/.rbenv/shims/ruby | |
| MIN_TEMP = 40.0 | |
| MAX_TEMP = 70.0 | |
| FANS = { | |
| 0 => { min: 2200, max: 6100, delta: 6100-2200 }, | |
| 1 => { min: 2100, max: 5600, delta: 5600-2100 } | |
| }.freeze | |
| temperature = `/usr/local/bin/smc -k TC0F -r`.match(/\d\d\.\d\d\d/).to_s.to_f | |
| delta_temp = temperature.to_f - MIN_TEMP | |
| delta_temp = delta_temp / (MAX_TEMP - MIN_TEMP) | |
| puts "#{temperature.to_i}°C" | |
| FANS.each do |id, attrs| | |
| speed = attrs[:min] + (delta_temp * attrs[:delta]) | |
| speed = [speed, attrs[:min]].max | |
| speed = [speed, attrs[:max]].min.to_i | |
| puts "fan#{id}: #{speed}" | |
| `/usr/local/bin/smc -k F#{id}Mn -w #{(speed << 2).to_s(16)}` | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment