Skip to content

Instantly share code, notes, and snippets.

@blueyed
Last active August 29, 2015 14:22
Show Gist options
  • Save blueyed/87f3fd0578a09a820ba4 to your computer and use it in GitHub Desktop.
Save blueyed/87f3fd0578a09a820ba4 to your computer and use it in GitHub Desktop.
battery widget for AwesomeWM
-- Battery widget {{{
batwidget = awful.widget.progressbar()
batwidget:set_width(8)
batwidget:set_vertical(true)
local batwidget_tooltip = awful.tooltip({ objects = { batwidget }, delay_show = 1, })
vicious.register(batwidget, vicious.widgets.bat, function(widget, args)
local state, percent, time, wear = unpack(args)
if state == "⌁" or state == "↯" then -- "Unknown" or "Charged"
widget:set_width(0)
else
widget:set_width(8)
if percent <= 25 then
widget:set_color("#FF5656")
else
widget:set_color("#AECF96")
end
end
batwidget_tooltip:set_text("bat: " .. state .. " " .. percent .. "%, time:" .. time .. ", wear: " .. wear )
return percent
end, 61, "BAT0")
-- }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment