summaryrefslogtreecommitdiff
path: root/rc.lua
diff options
context:
space:
mode:
authorNicolas Schodet2015-05-07 21:59:55 +0200
committerNicolas Schodet2015-05-07 22:01:36 +0200
commit3bbe7c6b3e95ca32e4bc653bb57e89b4333407b9 (patch)
tree28be288ed607c853860545a346025bcaf4828ec4 /rc.lua
parentd9ac8e2bec2ac5107a75e18d5edb53b48bf3a31e (diff)
add battery widget
Diffstat (limited to 'rc.lua')
-rw-r--r--rc.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/rc.lua b/rc.lua
index 3efde64..8119cf9 100644
--- a/rc.lua
+++ b/rc.lua
@@ -11,6 +11,7 @@ require("naughty")
require("debian.menu")
-- Load my modules
+require("vicious")
require("widgets.volume")
require("widgets.cal")
@@ -93,6 +94,31 @@ myvolumeicon = widget({ type = "imagebox" })
myvolumeicon.image = image(beautiful.widget_vol)
myvolumeicon:buttons (myvolume:buttons ())
+mybat = widget({ type = "textbox" })
+mybaticon = widget({ type = "imagebox" })
+mybaticon.image = image(beautiful.widget_bat)
+vicious.register(mybat, vicious.widgets.bat, function (widget, args)
+ -- If unknown, hide widget completely
+ if args[1] == "⌁" then
+ mybaticon.visible = false
+ mybat.visible = false
+ else
+ mybaticon.visible = true
+ mybat.visible = true
+ end
+ -- change color according to battery level
+ if args[2] < 20 then
+ color = beautiful.fg_bat_lo_widget
+ else
+ if args[2] > 80 then
+ color = beautiful.fg_bat_hi_widget
+ else
+ color = beautiful.fg_bat_mi_widget
+ end
+ end
+ return string.format('<span color="%s">%d%%</span>', color, args[2])
+end, 60, "BAT0")
+
myseparator = widget({ type = "imagebox" })
myseparator.image = image(beautiful.widget_sep)
@@ -166,6 +192,7 @@ for s = 1, screen.count() do
},
mylayoutbox[s],
myvolume, myvolumeicon,
+ mybat, mybaticon,
myseparator,
mytextclock,
s == 1 and mysystray or nil,