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:

no need to set naughty.config.defaults as preset, because it's implicit; closes #290
authorcopycat-killer <dada@archlinux.info>
Wed, 25 Jan 2017 16:28:37 +0000 (17:28 +0100)
committercopycat-killer <dada@archlinux.info>
Wed, 25 Jan 2017 16:28:37 +0000 (17:28 +0100)
helpers.lua
widgets/alsabar.lua
widgets/calendar.lua
widgets/contrib/task.lua
widgets/contrib/tpbat/init.lua
widgets/fs.lua
widgets/pulsebar.lua

index 7c446480c0cf6955698f8b5fd5835cd44ac8db3c..b1a195caafe9a9e9f44125012bbda2cda2cf1ba7 100644 (file)
@@ -185,6 +185,21 @@ 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 c3e3d9d95b970e6000f34924f16acd13dc53502c..ba1216c15100ce17102fe1e0534bf863d603e046 100644 (file)
@@ -50,8 +50,8 @@ local function worker(args)
     alsabar.notification_preset = args.notification_preset
 
     if not alsabar.notification_preset then
-        alsabar.notification_preset      = naughty.config.defaults
-        alsabar.notification_preset.font = "Monospace 11"
+        alsabar.notification_preset      = {}
+        alsabar.notification_preset.font = "Monospace 10"
     end
 
     local format_cmd = string.format("%s get %s", alsabar.cmd, alsabar.channel)
index 76284f541942815695724e500b090091bf58ee02..3ad34983bfda3d1621df80a979d5a1d5b4d5573c 100644 (file)
@@ -6,8 +6,7 @@
                                                   
 --]]
 
-local async        = require("lain.helpers").async
-local icons_dir    = require("lain.helpers").icons_dir
+local helpers      = require("lain.helpers")
 local markup       = require("lain.util.markup")
 local awful        = require("awful")
 local naughty      = require("naughty")
@@ -67,7 +66,7 @@ function calendar.show(t_out, inc_offset, scr)
         calendar.notification_preset.screen = src or 1
     end
 
-    async(f, function(ws)
+    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({
@@ -83,14 +82,15 @@ function calendar.attach(widget, args)
     local args                   = args or {}
     calendar.cal                 = args.cal or "/usr/bin/cal --color=always"
     calendar.followtag           = args.followtag or false
-    calendar.icons               = args.icons or icons_dir .. "cal/white/"
+    calendar.icons               = args.icons or helpers.icons_dir .. "cal/white/"
     calendar.notification_preset = args.notification_preset
 
     if not calendar.notification_preset then
-        calendar.notification_preset      = naughty.config.defaults
-        calendar.notification_preset.font = "Monospace 10"
-        calendar.notification_preset.fg   = "#FFFFFF"
-        calendar.notification_preset.bg   = "#000000"
+        calendar.notification_preset = {
+            font = "Monospace 10",
+            fg   = "#FFFFFF",
+            bg   = "#000000"
+        }
     end
 
     if widget then
index 4325437fe11dbf4a210a27d2082b86c91f53d2af..afc9f930d38a3da5b4eb4659113a92d9e79af767 100644 (file)
@@ -66,9 +66,10 @@ function task.attach(widget, args)
     task.notification_preset = args.notification_preset
 
     if not task.notification_preset then
-        task.notification_preset      = naughty.config.defaults
-        task.notification_preset.font = "Monospace 10"
-        task.notification_preset.icon = helpers.icons_dir .. "/taskwarrior.png"
+        task.notification_preset = {
+            font = "Monospace 10",
+            icon = helpers.icons_dir .. "/taskwarrior.png"
+        }
     end
 
     if widget then
index 3342e02b6a7c73e13df27eb770f1d5d0ee3e0f24..32a25275917665e9d06301d5837fbb090f1c181e 100644 (file)
@@ -51,10 +51,8 @@ function tpbat.show(t_out)
     local time   = bat:remaining_time()
     local msg    = "\t"
 
-    if status ~= "idle" and status ~= "nil"
-    then
-        if time == "N/A"
-        then
+    if status ~= "idle" and status ~= "nil" then
+        if time == "N/A" then
             msg = "...Calculating time remaining..."
         else
             msg = time .. (status == "charging" and " until charged" or " remaining")
@@ -67,10 +65,9 @@ function tpbat.show(t_out)
                 .. string.format("\n%s \t\t\t %s", status:upper(), msg)
 
     tpbat.notification = naughty.notify({
-        preset = naughty.config.defaults,
-        text = str,
+        text    = str,
         timeout = t_out,
-        screen = client.focus and client.focus.screen or 1
+        screen  = client.focus and client.focus.screen or 1
     })
 end
 
@@ -150,6 +147,7 @@ function tpbat.register(args)
         end
 
         widget = tpbat.widget
+
         settings()
     end
 
index e01aab853e0595eb6aced19ce2eb92ae4bd1d963..312a5e3b68c3610a6f3a34343d25f81adc26acc2 100644 (file)
@@ -61,10 +61,11 @@ local function worker(args)
     fs.notification_preset = args.notification_preset
 
     if not fs.notification_preset then
-        fs.notification_preset      = naughty.config.defaults
-        fs.notification_preset.font = "Monospace 10"
-        fs.notification_preset.fg   = "#FFFFFF"
-        fs.notification_preset.bg   = "#000000"
+        fs.notification_preset = {
+            font = "Monospace 10",
+            fg   = "#FFFFFF",
+            bg   = "#000000"
+        }
     end
 
     helpers.set_map(partition, false)
index 8cf8566ad83ff6e717c92495b27acef3577cc88c..db03b24186f77614f195850818df0fb72cf62a8f 100644 (file)
@@ -51,8 +51,8 @@ local function worker(args)
     pulsebar.notifications = args.notification_preset
 
     if not pulsebar.notification_preset then
-        pulsebar.notification_preset      = naughty.config.defaults
-        pulsebar.notification_preset.font = "Monospace 11"
+        pulsebar.notification_preset      = {}
+        pulsebar.notification_preset.font = "Monospace 10"
     end
 
     pulsebar.bar = wibox.widget {