Sha256: 3c30ffecbbb260b23564d494c5e26ef6cc846f1aac658ae671de9211c2d42361

Contents?: true

Size: 924 Bytes

Versions: 101

Compression:

Stored size: 924 Bytes

Contents

class Knj::Nvidia_settings
  attr_reader :data
  
  def initialize(data = {})
    @data = data
    @power_mizer_modes = {
      "adaptive" => 0,
      "performance" => 1
    }
  end
  
  def self.list(args = {})
    res = Knj::Os.shellcmd("nvidia-settings -q gpus")
    ret = []
    
    res.scan(/\[gpu:(\d+)\]/) do |gpu|
      ret << Knj::Nvidia_settings.new(args.merge({
        "gpu_no" => gpu[0]
      }))
    end
    
    return ret
  end
  
  def power_mizer_mode=(newval)
    raise "No such power-mizer-mode." if @power_mizer_modes[newval] == nil
    
    cmd = "nvidia-settings -a [gpu:#{@data["gpu_no"]}]/GPUPowerMizerMode=#{@power_mizer_modes[newval]}"
    res = Knj::Os.shellcmd(cmd)
    
    if res.index("assigned value") == nil
      raise res.strip
    end
  end
  
  def extra_args
    str = ""
    
    if @data["display"]
      str << " --display #{@data["display"]}"
    end
    
    return str
  end
end

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
knjrbfw-0.0.116 lib/knj/nvidia_settings.rb
knjrbfw-0.0.115 lib/knj/nvidia_settings.rb
knjrbfw-0.0.114 lib/knj/nvidia_settings.rb
knjrbfw-0.0.113 lib/knj/nvidia_settings.rb
knjrbfw-0.0.111 lib/knj/nvidia_settings.rb
knjrbfw-0.0.110 lib/knj/nvidia_settings.rb
knjrbfw-0.0.109 lib/knj/nvidia_settings.rb
knjrbfw-0.0.108 lib/knj/nvidia_settings.rb
knjrbfw-0.0.107 lib/knj/nvidia_settings.rb
knjrbfw-0.0.105 lib/knj/nvidia_settings.rb
knjrbfw-0.0.104 lib/knj/nvidia_settings.rb
knjrbfw-0.0.103 lib/knj/nvidia_settings.rb
knjrbfw-0.0.102 lib/knj/nvidia_settings.rb
knjrbfw-0.0.101 lib/knj/nvidia_settings.rb
knjrbfw-0.0.100 lib/knj/nvidia_settings.rb
knjrbfw-0.0.99 lib/knj/nvidia_settings.rb
knjrbfw-0.0.98 lib/knj/nvidia_settings.rb
knjrbfw-0.0.97 lib/knj/nvidia_settings.rb
knjrbfw-0.0.96 lib/knj/nvidia_settings.rb
knjrbfw-0.0.95 lib/knj/nvidia_settings.rb