From 4808f43077c9b4bf161e37c6fffc1e9dfbbccf98 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 5 Jan 2023 16:27:59 +0100 Subject: rc: add a battery level monitor to statusbar Consisting of: - battery object, which is a wrapper around a sysfs dir describing a battery - battery manager, which adds and removes individual batteries as they (dis)appear - e.g. wireless input devices, and maps them to widgets displayed side by side - battery widget, which shows the status of one of the batteries; the widget used is derived from batteryarc [1], but heavily modified [1] https://github.com/streetturtle/awesome-wm-widgets/ --- rc.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'rc.lua') diff --git a/rc.lua b/rc.lua index 43d5fe3..2bf47ca 100644 --- a/rc.lua +++ b/rc.lua @@ -16,8 +16,9 @@ local utils = require("utils") local workspace = require("workspace") -- local widgets -local pager = require("pager") -local urgent_wgt = require("urgent_wgt") +local BatteryManager = require("battery_mng") +local pager = require("pager") +local urgent_wgt = require("urgent_wgt") -- {{{ Error handling -- Check if awesome encountered an error during startup and fell back to @@ -79,6 +80,8 @@ update_systray_iconsize() -- global, shown only on the primary screen local u_wgt = urgent_wgt.UrgentWidget:new() +local b_mng = BatteryManager() + -- Create a wibox for each screen and add it mywibox = {} mypromptbox = {} @@ -103,12 +106,14 @@ awful.screen.connect_for_each_screen(function(s) awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) - local layoutbox_container = wibox.container.constraint(layoutbox, 'max', beautiful.xresources.apply_dpi(tray_icon_size)) local layout_utils = wibox.layout.fixed.horizontal() - layout_utils:add(layoutbox_container) + layout_utils:add(layoutbox) + layout_utils:add(b_mng) layout_utils:add(u_wgt.widget) + local utils_bar = wibox.container.constraint(layout_utils, 'max', nil, beautiful.xresources.apply_dpi(tray_icon_size)) + -- Create a tasklist widget local pgr = pager.Pager:new(wsp, s) @@ -117,7 +122,7 @@ awful.screen.connect_for_each_screen(function(s) layout_bottom:add(systray) - layout_bottom:add(layout_utils) + layout_bottom:add(utils_bar) layout_bottom:add(clock_time) layout_bottom:add(clock_date) -- cgit v1.2.3