From 5a7813951516bc99fa44e345e463fa71d32d0035 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Mon, 21 Mar 2022 12:56:53 +0000 Subject: [PATCH] Made the mailbox widget update properly --- widgets/mailbox.lua | 58 ++++++++++++++---------------------------- widgets/wallpapers.lua | 13 ---------- 2 files changed, 19 insertions(+), 52 deletions(-) diff --git a/widgets/mailbox.lua b/widgets/mailbox.lua index 0ba821e..f167c6a 100644 --- a/widgets/mailbox.lua +++ b/widgets/mailbox.lua @@ -6,8 +6,7 @@ local wibox = require("wibox") local naughty = require("naughty") local awmtk_status,awmtk = pcall(require,"awmtk") local dbus_config = require("naughty.dbus") -local widget = {} -local function worker(args) +return function(args) local args = args or {} -- Set up style variables style = awmtk.style(awmtk.defaults,args.style or {},"mailbox_") @@ -15,30 +14,24 @@ local function worker(args) style.mailbox_button_height = style.mailbox_button_heihgt or 40 args.mail_limit = args.mail_limit or 8 -- Create a notifications list - notifications_list = { + local notifications_list = wibox.widget { spacing = style.mailbox_container_spacing_vertical, layout = wibox.layout.fixed.vertical, } - -- Function to regenerate the popup - local gen_popup = function() - return awful.popup(style.container( + local notification_popup = awful.popup(style.container( + { { - { - text = "This widget will store your notification", - widget = wibox.widget.textbox - }, - notifications_list, - layout = wibox.layout.fixed.vertical, - forced_width = style.mailbox_container_width - },{ - visible = false, - ontop = true, - } - )) - end - - -- Initialize the popup - local notification_popup = gen_popup() + text = "Notifications: ", + widget = wibox.widget.textbox + }, + notifications_list, + layout = wibox.layout.fixed.vertical, + forced_width = style.mailbox_container_width + },{ + visible = false, + ontop = true, + } + )) -- Create a mailbox button args.screen.notify_widget = style.icon ( @@ -60,10 +53,8 @@ local function worker(args) end } ) - local notify_widget = args.screen.notify_widget - local update_notifications = function(update_args) - if notification_popup.visible then notification_popup.visible = false end - table.insert(notifications_list,1,style.button( + naughty.config.notify_callback = function(update_args) + notifications_list:add(style.button( { (update_args.icon and { image = update_args.icon, @@ -93,21 +84,10 @@ local function worker(args) end } )) - if #notifications_list >= args.mail_limit then - table.remove(notifications_list,args.mail_limit) - end - notification_popup = gen_popup() for s in screen do - s.notify_widget:emit_signal("notification::arrived") + s.notify_widget.bg = style.mailbox_button_bg_focus end return update_args end - args.screen.notify_widget:connect_signal("notification::arrived",function() - args.screen.notify_widget.bg = style.mailbox_button_bg_focus - end) - naughty.config.notify_callback = update_notifications - widget = notify_widget - return notify_widget + return args.screen.notify_widget end - -return setmetatable(widget, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/wallpapers.lua b/widgets/wallpapers.lua index 7ace017..2723c00 100644 --- a/widgets/wallpapers.lua +++ b/widgets/wallpapers.lua @@ -96,25 +96,12 @@ local function worker(args) },{},{ function() if popup.visible then - --rows = nil popup.visible = not popup.visible else - --init_popup() popup:move_next_to(mouse.current_widget_geometry) end end }) - widget = clip_widget - root.keys(gears.table.join( - root.keys(), - awful.key({global.modkey,"Control"},"b",function() - pager:next() - end), - awful.key({global.modkey,"Control"},"v",function() - pager:prev() - end) - )) - return clip_widget end