From: copycat-killer Date: Wed, 25 Jan 2017 16:28:37 +0000 (+0100) Subject: no need to set naughty.config.defaults as preset, because it's implicit; closes #290 X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/49a4df385e953156e6d1e2ee0bcfd07d8501d0f4?ds=sidebyside;hp=-c no need to set naughty.config.defaults as preset, because it's implicit; closes #290 --- 49a4df385e953156e6d1e2ee0bcfd07d8501d0f4 diff --git a/helpers.lua b/helpers.lua index 7c44648..b1a195c 100644 --- a/helpers.lua +++ b/helpers.lua @@ -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 diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index c3e3d9d..ba1216c 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -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) diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 76284f5..3ad3498 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -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 diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index 4325437..afc9f93 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -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 diff --git a/widgets/contrib/tpbat/init.lua b/widgets/contrib/tpbat/init.lua index 3342e02..32a2527 100644 --- a/widgets/contrib/tpbat/init.lua +++ b/widgets/contrib/tpbat/init.lua @@ -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 diff --git a/widgets/fs.lua b/widgets/fs.lua index e01aab8..312a5e3 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -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) diff --git a/widgets/pulsebar.lua b/widgets/pulsebar.lua index 8cf8566..db03b24 100644 --- a/widgets/pulsebar.lua +++ b/widgets/pulsebar.lua @@ -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 {