From de6cbd7c4afacb9178ab35cf78b7964c7ddd3d68 Mon Sep 17 00:00:00 2001 From: streetturtle Date: Sat, 4 Feb 2017 12:57:56 -0500 Subject: battery: fix icons naming for charing status --- battery-widget/battery.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'battery-widget') diff --git a/battery-widget/battery.lua b/battery-widget/battery.lua index cb07712..71d1823 100644 --- a/battery-widget/battery.lua +++ b/battery-widget/battery.lua @@ -7,6 +7,8 @@ local watch = require("awful.widget.watch") -- 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/status/symbolic/" + battery_widget = wibox.widget { { id = "icon", @@ -19,8 +21,6 @@ battery_widget = wibox.widget { end } -local path_to_icons = "/usr/share/icons/Arc/status/symbolic/" - watch( "acpi", 10, function(widget, stdout, stderr, exitreason, exitcode) @@ -28,15 +28,17 @@ watch( local _, status, charge_str, time = string.match(stdout, '(.+): (%a+), (%d?%d%d)%%,? ?.*') local charge = tonumber(charge_str) if (charge >= 0 and charge < 15) then - batteryType="battery-empty" + batteryType="battery-empty%s-symbolic" show_battery_warning() - 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" + elseif (charge >= 15 and charge < 40) then batteryType="battery-caution%s-symbolic" + elseif (charge >= 40 and charge < 60) then batteryType="battery-low%s-symbolic" + elseif (charge >= 60 and charge < 80) then batteryType="battery-good%s-symbolic" + elseif (charge >= 80 and charge <= 100) then batteryType="battery-full%s-symbolic" end if status == 'Charging' then - batteryType = batteryType .. '-charging' + batteryType = string.format(batteryType,'-charging') + else + batteryType = string.format(batteryType,'') end battery_widget.image = path_to_icons .. batteryType .. ".svg" end @@ -70,4 +72,4 @@ function show_battery_warning() end -- popup with battery info -battery_widget:connect_signal("mouse::enter", function() show_battery_status() end) +battery_widget:connect_signal("mouse::enter", function() show_battery_status() end) \ No newline at end of file -- cgit v1.2.3