diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2023-01-06 15:22:34 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2023-01-06 15:22:34 +0100 |
| commit | 1403c8f3b10149461f9319c75a69a1254f3cb273 (patch) | |
| tree | a196dde347567f38848b8cf00f9317a6f34688bc /awesome | |
| parent | 9073d9d28c7cb153f98f31c8a940f148c86c6f4a (diff) | |
awesome: rework info widgets
use graph for cpu, add memory widget
Diffstat (limited to 'awesome')
| -rw-r--r-- | awesome/rc.lua | 75 |
1 files changed, 55 insertions, 20 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua index 4b612b0..0e4cbb3 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -132,30 +132,64 @@ mytextclock = wibox.widget.textclock(' %H:%M ') mycalendar = awful.widget.calendar_popup.month({ position = 'tr', spacing = 1, }) mycalendar:attach(mytextclock) - -function bat_string(widget, state) - local charge = ' Bat:' .. state[2] .. '% ' - - if state[2] < 10 then - charge = '<span background="' .. beautiful.bg_urgent .. '">' .. charge .. '</span>' +function create_bat_widget() + local bat_name = "BAT0" + local fd = io.open("/sys/class/power_supply/" .. bat_name .. "/status") + if fd == nil then + return nil + else + io.close(fd) end - - return charge -end - -batwidget = wibox.widget.textbox() -vicious.register(batwidget, vicious.widgets.bat, bat_string, 60, "BAT0") - -function cpu_string(widget, loads) - local result = " CPU:" .. loads[2] .. "%" - for cpu = 3, #loads do - result = result .. "/" .. loads[cpu] .. "%" + function bat_string(widget, state) + local charge = ' 🔋' .. state[2] .. '% ' + if state[2] < 10 then + charge = '<span background="' .. beautiful.bg_urgent .. '">' .. charge .. '</span>' + end + return charge end - return result .. " " + local text = wibox.widget.textbox() + vicious.register(text, vicious.widgets.bat, bat_string, 60, bat_name) + return text end +local batwidget = create_bat_widget() -cpuwidget = wibox.widget.textbox() -vicious.register(cpuwidget, vicious.widgets.cpu, cpu_string, 2) +function create_cpu_widget() + local graph = wibox.widget { + color = beautiful.fg_normal, + background_color = beautiful.bg_normal, + widget = wibox.widget.graph + } + graph:set_width(50) + vicious.register(graph, vicious.widgets.cpu, "$1", 2) + return wibox.widget { + wibox.container.mirror(graph, { horizontal = true }), + wibox.widget.textbox(" CPU"), + layout = wibox.layout.stack + } +end +local cpuwidget = create_cpu_widget() + +function create_mem_widget() + local bar = wibox.widget { + color = beautiful.fg_normal, + background_color = beautiful.bg_normal, + border_width = beautiful.border_width, + border_color = beautiful.border_focus, + widget = wibox.widget.progressbar + } + vicious.register(bar, vicious.widgets.mem, "$1", 5) + local rotated_bar = wibox.widget { + wibox.container.constraint(bar, 'max', 0, 10), + direction = 'east', + layout = wibox.container.rotate + } + return wibox.widget { + wibox.widget.textbox(" Mem "), + rotated_bar, + layout = wibox.layout.fixed.horizontal + } +end +local memwidget = create_mem_widget() -- Create a wibox for each screen and add it local taglist_buttons = gears.table.join( @@ -263,6 +297,7 @@ awful.screen.connect_for_each_screen(function(s) layout = wibox.layout.fixed.horizontal, --mykeyboardlayout, cpuwidget, + memwidget, batwidget, s.mylayoutbox, wibox.widget.systray(), |
