]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

calendar: fix async hanging notifications; closes #289
authorcopycat-killer <dada@archlinux.info>
Wed, 25 Jan 2017 17:35:30 +0000 (18:35 +0100)
committercopycat-killer <dada@archlinux.info>
Wed, 25 Jan 2017 17:35:30 +0000 (18:35 +0100)
helpers.lua
widgets/alsabar.lua
widgets/calendar.lua
widgets/fs.lua
widgets/pulsebar.lua

index b1a195caafe9a9e9f44125012bbda2cda2cf1ba7..7c446480c0cf6955698f8b5fd5835cd44ac8db3c 100644 (file)
@@ -185,21 +185,6 @@ function helpers.make_widget_textbox()
     return t
 end
 
--- shallow copy a table
-function helpers.table_shallowcopy(orig)
-    local orig_type = type(orig)
-    local copy
-    if orig_type == 'table' then
-        copy = {}
-        for orig_key, orig_value in pairs(orig) do
-            copy[orig_key] = orig_value
-        end
-    else -- number, string, boolean, etc
-        copy = orig
-    end
-    return copy
-end
-
 -- }}}
 
 return helpers
index ba1216c15100ce17102fe1e0534bf863d603e046..90c60b4e254abda5dd029f35cae1b10df4f0d2aa 100644 (file)
@@ -119,10 +119,15 @@ local function worker(args)
 
             if alsabar.followtag then preset.screen = awful.screen.focused() end
 
-            alsabar.id = naughty.notify ({
-                replaces_id = alsabar.id,
-                preset      = preset
-            }).id
+            if not alsabar.notification then
+                alsabar.notification = naughty.notify {
+                    preset  = preset,
+                    destroy = function() alsabar.notification = nil end
+                }
+            else
+                naughty.replace_text(alsabar.notification, preset.title, preset.text)
+                naughty.reset_timeout(alsabar.notification, preset.timeout)
+            end
         end)
     end
 
index 3ad34983bfda3d1621df80a979d5a1d5b4d5573c..892d95495818cc030012262f70f8244da93efd45 100644 (file)
@@ -20,14 +20,10 @@ local tonumber     = tonumber
 local calendar = { offset = 0 }
 
 function calendar.hide()
-    if not calendar.notification then return end
-    naughty.destroy(calendar.notification)
-    calendar.notification = nil
+    naughty.destroy(naughty.getById(calendar.id))
 end
 
 function calendar.show(t_out, inc_offset, scr)
-    calendar.hide()
-
     local today = os.date("%d")
     local offs = inc_offset or 0
     local f
@@ -69,12 +65,13 @@ function calendar.show(t_out, inc_offset, scr)
     helpers.async(f, function(ws)
         fg, bg = calendar.notification_preset.fg, calendar.notification_preset.bg
         ws = ws:gsub("%c%[%d+[m]?%d+%c%[%d+[m]?", markup.bold(markup.color(bg, fg, today)))
-        calendar.notification = naughty.notify({
-            preset  = calendar.notification_preset,
-            text    = ws:gsub("\n*$", ""),
-            icon    = calendar.notify_icon,
-            timeout = t_out or calendar.notification.preset.timeout or 5
-        })
+        calendar.id = naughty.notify({
+            replaces_id = calendar.id,
+            preset      = calendar.notification_preset,
+            text        = ws:gsub("\n*$", ""),
+            icon        = calendar.notify_icon,
+            timeout     = t_out or calendar.notification.preset.timeout or 5
+        }).id
     end)
 end
 
index 312a5e3b68c3610a6f3a34343d25f81adc26acc2..4e9f04b29268ba12bf3598d475a36fa346dd9c9c 100644 (file)
@@ -61,11 +61,10 @@ local function worker(args)
     fs.notification_preset = args.notification_preset
 
     if not fs.notification_preset then
-        fs.notification_preset = {
-            font = "Monospace 10",
-            fg   = "#FFFFFF",
-            bg   = "#000000"
-        }
+        fs.notification_preset      = naughty.config.defaults
+        fs.notification_preset.font = "Monospace 10"
+        fs.notification_preset.fg   = "#FFFFFF"
+        fs.notification_preset.bg   = "#000000"
     end
 
     helpers.set_map(partition, false)
@@ -125,7 +124,7 @@ local function worker(args)
 
     helpers.newtimer(partition, timeout, fs.update)
 
-    return fs
+    return setmetatable(fs, { __index = fs.widget })
 end
 
 return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
index db03b24186f77614f195850818df0fb72cf62a8f..5453b1f1b7ed203636ecfe72f20a27399c0a437d 100644 (file)
@@ -129,10 +129,15 @@ local function worker(args)
 
             if pulsebar.followtag then preset.screen = awful.screen.focused() end
 
-            pulsebar.id = naughty.notify ({
-                replaces_id = pulsebar.id,
-                preset      = preset
-            }).id
+            if not pulsebar.notification then
+                pulsebar.notification = naughty.notify {
+                    preset  = preset,
+                    destroy = function() pulsebar.notification = nil end
+                }
+            else
+                naughty.replace_text(pulsebar.notification, preset.title, preset.text)
+                naughty.reset_timeout(pulsebar.notification, preset.timeout)
+            end
         end)
     end