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.94 lib/knj/nvidia_settings.rb
knjrbfw-0.0.93 lib/knj/nvidia_settings.rb
knjrbfw-0.0.92 lib/knj/nvidia_settings.rb
knjrbfw-0.0.91 lib/knj/nvidia_settings.rb
knjrbfw-0.0.90 lib/knj/nvidia_settings.rb
knjrbfw-0.0.89 lib/knj/nvidia_settings.rb
knjrbfw-0.0.88 lib/knj/nvidia_settings.rb
knjrbfw-0.0.87 lib/knj/nvidia_settings.rb
knjrbfw-0.0.86 lib/knj/nvidia_settings.rb
knjrbfw-0.0.85 lib/knj/nvidia_settings.rb
knjrbfw-0.0.84 lib/knj/nvidia_settings.rb
knjrbfw-0.0.83 lib/knj/nvidia_settings.rb
knjrbfw-0.0.82 lib/knj/nvidia_settings.rb
knjrbfw-0.0.81 lib/knj/nvidia_settings.rb
knjrbfw-0.0.80 lib/knj/nvidia_settings.rb
knjrbfw-0.0.79 lib/knj/nvidia_settings.rb
knjrbfw-0.0.78 lib/knj/nvidia_settings.rb
knjrbfw-0.0.77 lib/knj/nvidia_settings.rb
knjrbfw-0.0.75 lib/knj/nvidia_settings.rb
knjrbfw-0.0.74 lib/knj/nvidia_settings.rb