From: WooParadog Date: Sat, 19 Jul 2014 14:36:15 +0000 (+0800) Subject: show notification window in focused screen X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/b3e4d796d0aa6e2f697aa61b6d89f5e754703d01?ds=inline show notification window in focused screen --- diff --git a/widgets/alsabar.lua b/widgets/alsabar.lua index 365ac2d..4ae12e5 100644 --- a/widgets/alsabar.lua +++ b/widgets/alsabar.lua @@ -54,22 +54,22 @@ local alsabar = function alsabar.notify() alsabar.update() - local preset = - { + local preset = + { title = "", text = "", timeout = 4, font = alsabar.notifications.font .. " " .. alsabar.notifications.font_size, fg = alsabar.notifications.color - } + } - if alsabar._muted + if alsabar._muted then - preset.title = alsabar.channel .. " - Muted" - else - preset.title = alsabar.channel .. " - " .. alsabar._current_level * 100 .. "%" - end + preset.title = alsabar.channel .. " - Muted" + else + preset.title = alsabar.channel .. " - " .. alsabar._current_level * 100 .. "%" + end int = math.modf(alsabar._current_level * alsabar.notifications.bar_size) preset.text = "[" @@ -78,15 +78,17 @@ function alsabar.notify() .. "]" if alsabar._notify ~= nil then - alsabar._notify = naughty.notify ({ + alsabar._notify = naughty.notify ({ replaces_id = alsabar._notify.id, - preset = preset + preset = preset, + screen = client.focus and client.focus.screen or 1 }) - else - alsabar._notify = naughty.notify ({ - preset = preset + else + alsabar._notify = naughty.notify ({ + preset = preset, + screen = client.focus and client.focus.screen or 1 }) - end + end end local function worker(args) diff --git a/widgets/bat.lua b/widgets/bat.lua index 1d8f8c3..2ace758 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -129,13 +129,15 @@ local function worker(args) then bat.id = naughty.notify({ preset = bat_notification_critical_preset, - replaces_id = bat.id + replaces_id = bat.id, + screen = client.focus and client.focus.screen or 1 }).id elseif nperc <= 15 then bat.id = naughty.notify({ preset = bat_notification_low_preset, - replaces_id = bat.id + replaces_id = bat.id, + screen = client.focus and client.focus.screen or 1 }).id end end diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 61451fc..4e6eda7 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -98,7 +98,8 @@ function calendar:show(t_out, inc_offset) position = calendar.position, fg = calendar.fg, bg = calendar.bg, - timeout = tims + timeout = tims, + screen = client.focus and client.focus.screen or 1 }) end diff --git a/widgets/contrib/task.lua b/widgets/contrib/task.lua index a6c9f31..6e6ebae 100644 --- a/widgets/contrib/task.lua +++ b/widgets/contrib/task.lua @@ -51,7 +51,9 @@ function task:show() position = task.position, fg = task.fg, bg = task.bg, - timeout = task.timeout }) + timeout = task.timeout, + screen = client.focus and client.focus.screen or 1 + }) end function task:prompt_add() @@ -72,7 +74,8 @@ function task:prompt_add() position = task.position, fg = task.fg, bg = task.bg, - timeout = task.timeout + timeout = task.timeout, + screen = client.focus and client.focus.screen or 1 }) end, nil, @@ -105,7 +108,8 @@ function task:prompt_search() position = task.position, fg = task.fg, bg = task.bg, - timeout = task.timeout + timeout = task.timeout, + screen = client.focus and client.focus.screen or 1 }) end, nil, diff --git a/widgets/contrib/tpbat/init.lua b/widgets/contrib/tpbat/init.lua index 72d6453..782bf35 100644 --- a/widgets/contrib/tpbat/init.lua +++ b/widgets/contrib/tpbat/init.lua @@ -75,7 +75,8 @@ function tpbat:show(t_out) tpbat_notification = naughty.notify({ preset = { fg = beautiful.fg_normal }, text = str, - timeout = t_out + timeout = t_out, + screen = client.focus and client.focus.screen or 1 }) end @@ -111,7 +112,8 @@ function tpbat.register(args) local n = naughty.notify({ preset = bat_notification_low_preset, title = "SMAPI Battery Warning: Unable to read battery state!", - text = "This widget is intended for ThinkPads. Is tp_smapi installed? Check your configs & paths." + text = "This widget is intended for ThinkPads. Is tp_smapi installed? Check your configs & paths.", + screen = client.focus and client.focus.screen or 1 }) end @@ -137,13 +139,15 @@ function tpbat.register(args) then tpbat.id = naughty.notify({ preset = bat_notification_critical_preset, - replaces_id = tpbat.id + replaces_id = tpbat.id, + screen = client.focus and client.focus.screen or 1 }).id elseif bat_now.perc <= 15 then tpbat.id = naughty.notify({ preset = bat_notification_low_preset, - replaces_id = tpbat.id + replaces_id = tpbat.id, + screen = client.focus and client.focus.screen or 1 }).id end end diff --git a/widgets/fs.lua b/widgets/fs.lua index 79f821e..867ce3f 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -46,7 +46,8 @@ function fs:show(t_out) notification = naughty.notify({ preset = fs_notification_preset, text = ws, - timeout = t_out + timeout = t_out, + screen = client.focus and client.focus.screen or 1 }) end @@ -66,7 +67,6 @@ local function worker(args) function update() fs_info = {} fs_now = {} - local f = io.popen("LC_ALL=C df -kP " .. partition) for line in f:lines() do -- Match: (size) (used)(avail)(use%) (mount) @@ -99,7 +99,8 @@ local function worker(args) text = partition .. " ran out!\nmake some room", timeout = 8, fg = "#000000", - bg = "#FFFFFF" + bg = "#FFFFFF", + screen = client.focus and client.focus.screen or 1 }) helpers.set_map("fs", true) else diff --git a/widgets/imap.lua b/widgets/imap.lua index 6104388..c404032 100644 --- a/widgets/imap.lua +++ b/widgets/imap.lua @@ -74,7 +74,11 @@ local function worker(args) else nt = mail .. " has " .. mailcount .. " new messages" end - naughty.notify({ preset = mail_notification_preset, text = nt }) + naughty.notify({ + preset = mail_notification_preset, + text = nt, + screen = client.focus and client.focus.screen or 1 + }) end helpers.set_map(mail, mailcount) diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 1749b57..73efebb 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -92,7 +92,8 @@ local function worker(args) mpd.id = naughty.notify({ preset = mpd_notification_preset, icon = "/tmp/mpdcover.png", - replaces_id = mpd.id + replaces_id = mpd.id, + screen = client.focus and client.focus.screen or 1 }).id end elseif mpd_now.state ~= "pause" diff --git a/widgets/net.lua b/widgets/net.lua index 08c7366..1e59731 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -87,7 +87,8 @@ local function worker(args) timeout = 7, position = "top_left", icon = helpers.icons_dir .. "no_net.png", - fg = notify_fg or "#FFFFFF" + fg = notify_fg or "#FFFFFF", + screen = client.focus and client.focus.screen or 1 }) helpers.set_map(iface, false) end diff --git a/widgets/yawn/init.lua b/widgets/yawn/init.lua index 4109d6c..da2b856 100644 --- a/widgets/yawn/init.lua +++ b/widgets/yawn/init.lua @@ -161,7 +161,8 @@ function yawn.show(t_out) preset = yawn_notification_preset, text = weather_data, icon = sky, - timeout = t_out + timeout = t_out, + screen = client.focus and client.focus.screen or 1 }) end