|
|
@ -42,7 +42,7 @@ end |
|
|
|
|
|
|
|
return function(args) |
|
|
|
local style = awmtk2.create_style("battery", |
|
|
|
awmtk2.generic.status_widget,args.style) |
|
|
|
awmtk2.generic.popup,args.style) |
|
|
|
local templates = awmtk2.create_template_lib("battery",awmtk2.templates,args.templates) |
|
|
|
local t = awmtk2.build_templates(templates,style) |
|
|
|
-- set up popup layout |
|
|
@ -52,34 +52,39 @@ return function(args) |
|
|
|
}) |
|
|
|
-- create popup |
|
|
|
local popup = awful.popup(t.popup(layout)) |
|
|
|
-- create battery widget |
|
|
|
local battery_widget = wibox.widget(t.button({ |
|
|
|
{ |
|
|
|
image = beautiful["battery-missing-symbolic"], |
|
|
|
resize = true, |
|
|
|
widget = wibox.widget.imagebox, |
|
|
|
id = "virtual_id" |
|
|
|
}, |
|
|
|
(args.percentage and { |
|
|
|
markup = "0%", |
|
|
|
id = "percentage_id", |
|
|
|
widget = wibox.widget.textbox |
|
|
|
}), |
|
|
|
layout = wibox.layout.fixed.horizontal, |
|
|
|
spacing = style.base.spacing |
|
|
|
})) |
|
|
|
-- make it possible to press the button and make it toggle the popup |
|
|
|
battery_widget:connect_signal("button::press",style.button.onpress) |
|
|
|
battery_widget:connect_signal("button::release",style.button.onrelease) |
|
|
|
battery_widget:connect_signal("button::press",function(self,x,y,button) |
|
|
|
if button == 1 then |
|
|
|
popup.visible = (not popup.visible) |
|
|
|
if popup.visible then |
|
|
|
popup:move_next_to(mouse.current_widget_geometry) |
|
|
|
local battery_widget |
|
|
|
do -- create battery widget |
|
|
|
local style = awmtk2.create_style("battery", |
|
|
|
awmtk2.generic.status_widget,args.style) |
|
|
|
local templates = awmtk2.create_template_lib("battery",awmtk2.templates,args.templates) |
|
|
|
local t = awmtk2.build_templates(templates,style) |
|
|
|
battery_widget = wibox.widget(t.button({ |
|
|
|
{ |
|
|
|
image = beautiful["battery-missing-symbolic"], |
|
|
|
resize = true, |
|
|
|
widget = wibox.widget.imagebox, |
|
|
|
id = "virtual_id" |
|
|
|
}, |
|
|
|
(args.percentage and { |
|
|
|
markup = "0%", |
|
|
|
id = "percentage_id", |
|
|
|
widget = wibox.widget.textbox |
|
|
|
}), |
|
|
|
layout = wibox.layout.fixed.horizontal, |
|
|
|
spacing = style.base.spacing |
|
|
|
})) |
|
|
|
-- make it possible to press the button and make it toggle the popup |
|
|
|
battery_widget:connect_signal("button::press",style.button.onpress) |
|
|
|
battery_widget:connect_signal("button::release",style.button.onrelease) |
|
|
|
battery_widget:connect_signal("button::press",function(self,x,y,button) |
|
|
|
if button == 1 then |
|
|
|
popup.visible = (not popup.visible) |
|
|
|
if popup.visible then |
|
|
|
popup:move_next_to(mouse.current_widget_geometry) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end) |
|
|
|
|
|
|
|
end) |
|
|
|
end |
|
|
|
-- map widgets to their names to make it easier to update separate components |
|
|
|
local widget_map = {} |
|
|
|
-- also map current charge state of every device to get the icon for the tray |
|
|
|