Skip to content

lua function to get a formatted string with the current battery status. Can be used to fill a text widget in the awesome window manager.

Notifications You must be signed in to change notification settings

tauceti2/awesome-batteryInfo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

awesome-batteryInfo

This is a small lua function that returns a formatted string with the current battery status. It can be used to populate a text widget in the awesome window manager. Based on the "Gigamo Battery Widget" found in the wiki at awesome.naquadah.org

Usage

Place the battery.lua file in the same directory as your main config file (e.g. rc.lua), and require it:

awesome < 3.5

  require("battery")

awesome >= 3.5

  local battery = require("battery")

Add a textbox to your wibox that will contain your battery status:

awesome < 3.5

  batterywidget = widget({type = "textbox", name = "batterywidget", align = "right" })
  (...)
  mytextclock,
  batterywidget,
  s == 1 and mysystray or nil,
  (...)

awesome >= 3.5

  batterywidget = wibox.widget.textbox()
  (...)
  local right_layout = wibox.layout.fixed.horizontal()
  right_layout:add(batterywidget)
  if s == 1 then right_layout:add(wibox.widget.systray()) end
  (...)

Add a hook that will update the widget every so often:

awesome < 3.5

  awful.hooks.timer.register(60, function()
    batterywidget.text = batteryInfo("BAT0")
  end)

awesome >= 3.5

  batterywidget_timer = timer({timeout = 1})
  batterywidget_timer:connect_signal("timeout", function()
    batterywidget:set_text(batteryInfo("BAT0"))
  end)
  batterywidget_timer:start()

If you don't want to wait for the battery status to appear until the function gets called by the hook, add the following somewhere after the declaration of the batterywidget.

awesome < 3.5

  batterywidget.text = batteryInfo("BAT0")

awesome >= 3.5

  batterywidget:set_text(batteryInfo("BAT0"))

About

lua function to get a formatted string with the current battery status. Can be used to fill a text widget in the awesome window manager.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%