module Barabara

This module provides battery status functionality. At the moment it just reads a status file from kernel's sysfs, so it only supports Linux.

TODO Add Upower support and make it possible to select the preferred mode from config.

Constants

DEFAULT_CONF
VERSION

Public Class Methods

run_app() click to toggle source
# File lib/barabara.rb, line 14
def self.run_app
  require 'optimist'
  opts = Optimist::options do
    opt :config, "Path to config file",
        type: :string, default: DEFAULT_CONF
  end

  config_path = check_config(opts[:config])
  @app = App.new(config_path)
  @app.run
end

Private Class Methods

check_config(path) click to toggle source
# File lib/barabara.rb, line 28
def self.check_config(path)
  config_path = File.expand_path path
  if ! File.exists? config_path
    if path == DEFAULT_CONF
      warn 'Config file not found at default location!'
      warn 'Will write a new one right now...'
      # TODO dump default config to a file.
      Configuration.dump_default_config(config_path)
    else
      warn "Config file \"#{path}\" not found!"
      exit 1
    end
  end

  config_path
end