Sha256: 753dd79e165046ce38aff569f0e6bef41245fe25a5f311d3467d6bf622f044cc

Contents?: true

Size: 695 Bytes

Versions: 61

Compression:

Stored size: 695 Bytes

Contents

class Knj::Power_manager
  def initialize(args = {})
    @args = args
    
    if !File.exists?("/proc/acpi/ac_adapter")
      raise "Could not find the proc-acpi folder."
    end
    
    Dir.new("/proc/acpi/ac_adapter").each do |file|
      next if file == "." or file == ".."
      fn = "/proc/acpi/ac_adapter/#{file}"
      
      if File.directory?(fn)
        @ac_folder = Knj::Php.realpath(fn)
        break
      end
    end
    
    raise "Could not register ac-folder." if !@ac_folder
  end
  
  def state
    cont = File.read("#{@ac_folder}/state")
    
    if match = cont.match(/state:\s*(.+)\s*/)
      return match[1]
    end
    
    raise "Could not figure out state."
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
knjrbfw-0.0.72 lib/knj/power_manager.rb
knjrbfw-0.0.71 lib/knj/power_manager.rb
knjrbfw-0.0.70 lib/knj/power_manager.rb
knjrbfw-0.0.69 lib/knj/power_manager.rb
knjrbfw-0.0.68 lib/knj/power_manager.rb
knjrbfw-0.0.67 lib/knj/power_manager.rb
knjrbfw-0.0.66 lib/knj/power_manager.rb
knjrbfw-0.0.65 lib/knj/power_manager.rb
knjrbfw-0.0.64 lib/knj/power_manager.rb
knjrbfw-0.0.63 lib/knj/power_manager.rb
knjrbfw-0.0.62 lib/knj/power_manager.rb
knjrbfw-0.0.59 lib/knj/power_manager.rb
knjrbfw-0.0.58 lib/knj/power_manager.rb
knjrbfw-0.0.57 lib/knj/power_manager.rb
knjrbfw-0.0.55 lib/knj/power_manager.rb
knjrbfw-0.0.54 lib/knj/power_manager.rb
knjrbfw-0.0.53 lib/knj/power_manager.rb
knjrbfw-0.0.52 lib/knj/power_manager.rb
knjrbfw-0.0.51 lib/knj/power_manager.rb
knjrbfw-0.0.50 lib/knj/power_manager.rb