From d18e5074d24ba2d8dd1a68a328d7ca6cfada352d Mon Sep 17 00:00:00 2001 From: Yessiest Date: Thu, 14 Apr 2022 20:14:57 +0400 Subject: [PATCH] u u h h h h --- libs/awmtk2.lua | 4 +++- widgets/battery.lua | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/awmtk2.lua b/libs/awmtk2.lua index 6a9a902..b4ca554 100644 --- a/libs/awmtk2.lua +++ b/libs/awmtk2.lua @@ -7,7 +7,7 @@ local awmtk = {} -- {{{ Utils -awmtk.subclass = function(parent_class,instance_overrides,name) +awmtk.create_namespace = function(parent_class,instance_overrides,name) return setmetatable(instance_overrides,{ __index = function(self,k) if rawget(self,k) then @@ -21,6 +21,8 @@ awmtk.subclass = function(parent_class,instance_overrides,name) }) end +awmtk.create_class = function + -- }}} diff --git a/widgets/battery.lua b/widgets/battery.lua index 6f22842..4238806 100644 --- a/widgets/battery.lua +++ b/widgets/battery.lua @@ -31,10 +31,13 @@ return function(args) local icon_name = out:match("icon%-name:%s+'(battery%-[^']+)'") local value = out:match("percentage:%s+(%d+%%)") icon:get_children_by_id("widget_icon")[1].image = - style[icon_name:gsub("%-","_")] - if args.percentage and value then + style[(icon_name or ""):gsub("%-","_")] + if args.percentage and value and icon_name then icon:get_children_by_id("widget_text")[1].markup = value end + if not icon_name then + icon:get_children_by_id("widget_text")[1].markup = "" + end end) end }