diff options
author | Tim Keller <tjk@tjkeller.xyz> | 2024-10-19 19:18:03 -0500 |
---|---|---|
committer | Tim Keller <tjk@tjkeller.xyz> | 2024-10-19 19:18:03 -0500 |
commit | cc68c3adcde665ca63ae0873e4dfca8c94a7c9e0 (patch) | |
tree | b34fc03f228563c23fd74b5d9bee25f07a76bc30 | |
parent | 95939ecf82851d9c5e0ee05aa1307617e67df451 (diff) | |
download | awesome-cc68c3adcde665ca63ae0873e4dfca8c94a7c9e0.tar.xz awesome-cc68c3adcde665ca63ae0873e4dfca8c94a7c9e0.zip |
bat upd
-rw-r--r-- | bar.lua | 2 | ||||
-rw-r--r-- | widgets/battery.lua | 11 |
2 files changed, 10 insertions, 3 deletions
@@ -53,7 +53,7 @@ local widgets = { wibox.widget.textbox "CPU: ", widget_cpu_usage, wibox.widget.textbox "% ", - widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", + widget_temperature "/sys/class/hwmon/hwmon2/temp1_input", -- FIXME wibox.widget.textbox "°", }, ram = { diff --git a/widgets/battery.lua b/widgets/battery.lua index 83a7fd0..873f1ba 100644 --- a/widgets/battery.lua +++ b/widgets/battery.lua @@ -2,7 +2,7 @@ local awful = require("awful") local wibox = require("wibox") local naughty = require("naughty") --- tooltip function +-- tooltip text function local tooltip_text_format = [[ <b>%s (%s)</b> Status: %s @@ -16,18 +16,22 @@ Technology: %s Manufacturer: %s Serial Number: %s ]] + function bat_uevents() -- TODO io.popen will stop execution local uevents = io.popen("ls /sys/class/power_supply/*/uevent") local text = "" + -- loop over uevent files for uevent in uevents:lines() do local ueventf = io.open(uevent) - local ueventc = ueventf:read('a') --:gmatch("%d+") + local ueventc = ueventf:read('a') ueventf:close() + -- get attributes local a = {} for k, v in ueventc:gmatch("POWER_SUPPLY_(.-)=%s*(.-)\n") do a[k] = v end + -- add to tooltip text if a.TYPE == "Battery" then local capacity = a.ENERGY_NOW * 100 / a.ENERGY_FULL local health = a.ENERGY_FULL * 100 / a.ENERGY_FULL_DESIGN @@ -50,6 +54,9 @@ function bat_uevents() end end uevents:close() + if text == "" then + return "No Batteries Installed" + end return text end |