amdgpu_fan 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 679327c6e2e0ed564648da7eeb4105c28a993467
4
+ data.tar.gz: '00503126847b6e208c21fb39bbde6908db3bf745'
5
+ SHA512:
6
+ metadata.gz: 4076bfa0d580658504f0b756b10a30450025dd51289f2bbd9eeb2782c4037b7a4b90b0656a21fea071ec3693aff5240be64038a08a5209b4d17614462b813cad
7
+ data.tar.gz: dc919a1fc850e907b9d8ca5bae7e670d1fbbc9d51ac4963e8b18cb050ce14d6833fa4b9e3f5a03d0e24e6f9dbeabd92d41907564e2c1596d67797684dcc2cf8b
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # amdgpu-fan-rb
2
+
3
+ A Ruby CLI to read and set the fan speed for AMD Radeon graphics cards running on the AMDGPU Linux driver.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ bin/amdgpu_fan
9
+ Commands:
10
+ amdgpu_fan help [COMMAND] # Describe available commands or one specific command
11
+ amdgpu_fan set PERCENTAGE # set fan speed to PERCENTAGE
12
+ amdgpu_fan status # report the current status
13
+ ```
data/bin/amdgpu_fan ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative '../lib/amdgpu_fan_cli'
5
+
6
+ AmdgpuFanCli.start ARGV
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ # The main class
6
+ class AmdgpuFanCli < Thor
7
+ FAN_POWER_FILE = '/sys/class/drm/card0/device/hwmon/hwmon2/pwm1'
8
+
9
+ desc 'set PERCENTAGE', 'set fan speed to PERCENTAGE'
10
+ def set(percentage)
11
+ return unless (0..100).cover?(percentage.to_i)
12
+ puts "Setting fan to #{setting_from_percent percentage}/#{max}..."
13
+ `sudo su -c "echo #{setting_from_percent percentage} > #{FAN_POWER_FILE}"`
14
+ end
15
+
16
+ desc 'status', 'report the current status'
17
+ def status
18
+ puts device_info,
19
+ "GPU fan running at #{current_percentage.round}% ~ #{rpm} rpm"
20
+ end
21
+
22
+ private
23
+
24
+ def device_info
25
+ @device_info ||= `glxinfo | grep -m 1 -o "AMD Radeon .* Series"`.strip
26
+ end
27
+
28
+ def current
29
+ `cat #{FAN_POWER_FILE}`
30
+ end
31
+
32
+ def current_percentage
33
+ current.to_f / max.to_i * 100
34
+ end
35
+
36
+ def max
37
+ @max ||= `cat /sys/class/drm/card0/device/hwmon/hwmon2/pwm1_max`.to_i
38
+ end
39
+
40
+ def rpm
41
+ `cat /sys/class/drm/card0/device/hwmon/hwmon2/fan1_input`.strip
42
+ end
43
+
44
+ def setting_from_percent(percent)
45
+ (percent.to_f / 100 * max.to_i).round
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amdgpu_fan
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kevin McCormack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A CLI for amdgpu fans
14
+ email: harlemsquirrel@gmail.com
15
+ executables:
16
+ - amdgpu_fan
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.md
21
+ - bin/amdgpu_fan
22
+ - lib/amdgpu_fan_cli.rb
23
+ homepage: https://github.com/HarlemSquirrel/amdgpu-fan-rb
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.6.13
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: A CLI to view and set fan speeds for AMD graphics cards running on the open
47
+ source amdgpu Linux driver
48
+ test_files: []