summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bar.lua2
-rw-r--r--widgets/battery.lua11
2 files changed, 10 insertions, 3 deletions
diff --git a/bar.lua b/bar.lua
index c03466e..c611afc 100644
--- a/bar.lua
+++ b/bar.lua
@@ -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