Skip to content

Instantly share code, notes, and snippets.

@butchler
Created March 3, 2013 06:50
Show Gist options
  • Save butchler/5075038 to your computer and use it in GitHub Desktop.
Save butchler/5075038 to your computer and use it in GitHub Desktop.
Battery indicator snippet from my AwesomeWM rc.lua.
...
-- Battery level widget
-- Create widget to show battery level
batterywidget = wibox.widget.textbox()
-- Create timer to update widget
batterytimer = timer({ timeout = 30 })
batterytimer:connect_signal("timeout", function()
local battery_info = vicious.widgets.bat("This argument doesn't seem to be used for anything.", "BAT0")
local battery_percentage = battery_info[2]
batterywidget:set_text(" | " .. battery_percentage .. "% | ")
end)
batterytimer:start()
-- Trigger timeout immediately so that it shows the battery level as soon as awesome starts
batterytimer:emit_signal("timeout")
...
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
right_layout:add(batterywidget)
right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment