summaryrefslogtreecommitdiff
path: root/battery-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2017-02-03 22:15:16 -0500
committerstreetturtle <streetturtle@gmail.com>2017-02-03 22:15:16 -0500
commit52590602d91d705c9a356359b56f45c55cb4d9d8 (patch)
treef4a185265c806459cf8e9a225730d1877eca42c3 /battery-widget
parent78fa8e629da7ea64ed54a2a8d6d08857b83e4324 (diff)
improve widget rendering and use wibox.widget wrapper
Diffstat (limited to 'battery-widget')
-rw-r--r--battery-widget/battery.lua30
1 files changed, 21 insertions, 9 deletions
diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua
index b2c78e7..2633ba2 100644
--- a/battery-widget/battery.lua
+++ b/battery-widget/battery.lua
@@ -3,27 +3,37 @@ local awful = require("awful")
local naughty = require("naughty")
local watch = require("awful.widget.watch")
-battery_widget = wibox.widget { widget = wibox.widget.imagebox }
-
-- acpi sample outputs
-- Battery 0: Discharging, 75%, 01:51:38 remaining
-- Battery 0: Charging, 53%, 00:57:43 until charged
-local path_to_icons = "/usr/share/icons/Arc/panel/22/"
+battery_widget = wibox.widget {
+ {
+ id = "icon",
+ widget = wibox.widget.imagebox,
+ resize = false
+ },
+ layout = wibox.container.margin(brightness_icon, 0, 0, 3),
+ set_image = function(self, path)
+ self.icon.image = path
+ end
+}
+
+local path_to_icons = "/usr/share/icons/Arc/status/symbolic/"
watch(
"acpi", 10,
function(widget, stdout, stderr, exitreason, exitcode)
local batteryType
- local _, status, charge, time = string.match(stdout, '(.+): (%a+), (%d%d)%%, (.+)')
+ local _, status, charge, time = string.match(stdout, '(.+): (%a+), (%d?%d%d)%%,? ?.*')
charge = tonumber(charge)
if (charge >= 0 and charge < 15) then
batteryType="battery-empty"
show_battery_warning()
- elseif (charge >= 15 and charge < 40) then batteryType="battery-caution"
- elseif (charge >= 40 and charge < 60) then batteryType="battery-low"
- elseif (charge >= 60 and charge < 80) then batteryType="battery-good"
- elseif (charge >= 80 and charge <= 100) then batteryType="battery-full"
+ elseif (charge >= 15 and charge < 40) then batteryType="battery-caution-symbolic"
+ elseif (charge >= 40 and charge < 60) then batteryType="battery-low-symbolic"
+ elseif (charge >= 60 and charge < 80) then batteryType="battery-good-symbolic"
+ elseif (charge >= 80 and charge <= 100) then batteryType="battery-full-symbolic"
end
if status == 'Charging' then
batteryType = batteryType .. '-charging'
@@ -47,13 +57,15 @@ end
function show_battery_warning()
naughty.notify{
+ icon = "/home/pashik/.config/awesome/nichosi.png",
+ icon_size=100,
text = "Huston, we have a problem",
title = "Battery is dying",
timeout = 5, hover_timeout = 0.5,
position = "bottom_right",
bg = "#F06060",
fg = "#EEE9EF",
- width = 200,
+ width = 300,
}
end