summaryrefslogtreecommitdiff
path: root/battery-widget/battery.lua
diff options
context:
space:
mode:
Diffstat (limited to 'battery-widget/battery.lua')
-rw-r--r--battery-widget/battery.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index 43cdaee..d84e591 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -38,7 +38,10 @@ local function worker(args)
local warning_msg_text = args.warning_msg_text or 'Battery is dying'
local warning_msg_position = args.warning_msg_position or 'bottom_right'
local warning_msg_icon = args.warning_msg_icon or HOME .. '/.config/awesome/awesome-wm-widgets/batteryarc-widget/spaceman.jpg'
- local disable_battery_warning = args.disable_battery_warning or false
+ local enable_battery_warning = args.enable_battery_warning
+ if enable_battery_warning == nil then
+ enable_battery_warning = true
+ end
if not gfs.dir_readable(path_to_icons) then
naughty.notify{
@@ -116,10 +119,8 @@ local function worker(args)
local battery_info = {}
local capacities = {}
for s in stdout:gmatch("[^\r\n]+") do
- local status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?.*')
- if string.match(s, 'rate information') then
- -- ignore such line
- elseif status ~= nil then
+ local status, charge_str, time = string.match(s, '.+: (%a+), (%d?%d?%d)%%,?(.*)')
+ if status ~= nil then
table.insert(battery_info, {status = status, charge = tonumber(charge_str)})
else
local cap_str = string.match(s, '.+:.+last full capacity (%d+)')
@@ -150,7 +151,7 @@ local function worker(args)
if (charge >= 0 and charge < 15) then
batteryType = "battery-empty%s-symbolic"
- if (not disable_battery_warning) and status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then
+ if enable_battery_warning and status ~= 'Charging' and os.difftime(os.time(), last_battery_check) > 300 then
-- if 5 minutes have elapsed since the last warning
last_battery_check = os.time()