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 /widgets | |
| parent | 95939ecf82851d9c5e0ee05aa1307617e67df451 (diff) | |
| download | awesome-cc68c3adcde665ca63ae0873e4dfca8c94a7c9e0.tar.xz awesome-cc68c3adcde665ca63ae0873e4dfca8c94a7c9e0.zip | |
bat upd
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/battery.lua | 11 | 
1 files changed, 9 insertions, 2 deletions
| 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 | 
