Hi, Changing naughty.lua:600 to local id = naughty.notify(args) --no .id results in notifications on all screens + no error! Thanks!
So, for clarification, my naughy.lua now looks like this on line 600: local id = naughty.notify(args) and my rc.lua looks like this where the local naughty module is defined: local naughty = require("naughty") naughty.notify_ = naughty.notify naughty.notify = function (args,...) for i = 1, screen.count() do args.screen = i naughty.notify_(args,...) end end @David: removing the .id part in naughty.lua:600 is necessary to prevent the error that happens when not trying to deal with keeping the id's in a table (which is what Alexis was suggesting). If I understand it correctly, if you want to be able to change the same notification without creating a new one, you have to manage the id's. e.g. without managing id's, changing the backlight from 0 to 100% might result in 100 1% notifications piling up! However, since I don't use high-frequency notifications on my desktop, I can ignore the need for notification id's for now. Thanks everyone! Abe On Fri, Jun 5, 2015 at 8:31 AM, David Sorkovsky <davidsorkov...@hotmail.com> wrote: > > > Of I understand the… > > > > local naughty = require("naughty") > naughty.notify_ = naughty.notify > naughty.notify = function (args,...) > for i = 1, screen.count() do > args.screen = i > naughty.notify_(args,...) > end > end > > > > > > … code correctly, would you even need to modify naughty.lua? > > > > > > Regards > > > > Dave > > > ------------------------------ > > *From:* Alexis BRENON [mailto:brenon.ale...@gmail.com] > *Sent:* Friday, 5 June 2015 11:07 PM > *To:* Abraham Baker > *Cc:* Elv1313 .; awesome > *Subject:* Re: Naughty Notifications on multiple monitors > > > > Instead of hidding the error just replace line 600 from: > local id = naughty.notify(args).id > > to > > naughty.notify(args) > > > > You don't need the id any more if you don't use it. This way, no more > error. > > Le ven. 5 juin 2015 à 14:57, Abraham Baker <z1693...@students.niu.edu> a > écrit : > > Hi, > > My goal is to get every notification to show up on all monitors. This > isn't critical; it just makes switching between standing/sitting easier. > > > I don't use often-updating notifications, so I (for now) don't care about > the notification id's. So, I'm thinking Elv1313's solution + hiding the > naughty.lua:600 error would be enough. > > > > The relevant part of my rc.lua: > > -- Standard awesome library > local gears = require("gears") > local awful = require("awful") > awful.rules = require("awful.rules") > require("awful.autofocus") > -- Widget and layout library > local wibox = require("wibox") > -- Theme handling library > local beautiful = require("beautiful") > -- Notification library > > > local naughty = require("naughty") > naughty.notify_ = naughty.notify > naughty.notify = function (args,...) > for i = 1, screen.count() do > args.screen = i > naughty.notify_(args,...) > end > end > > local menubar = require("menubar") > local revelation=require("revelation") > -- {{{ Error handling > -- Check if awesome encountered an error during startup and fell back to > -- another config (This code will only ever execute for the fallback > config) > if awesome.startup_errors then > naughty.notify({ preset = naughty.config.presets.critical, > title = "Oops, there were errors during startup!", > text = awesome.startup_errors }) > end > > -- Handle runtime errors after startup > do > local in_error = false > awesome.connect_signal("debug::error", function (err) > -- Make sure we don't go into an endless error loop > if in_error then return end > in_error = true > > naughty.notify({ preset = naughty.config.presets.critical, > title = "Oops, an error happened!", > text = err }) > in_error = false > end) > end > -- }}} > > The relevant part of naughty.lua (the only part changed from default): > local id = naughty.notify(args).id > return "u", id > --local notifs = naughty.notify(args) > --local id = {} > --for notif in ipairs(notifs) do > -- id:insert(notif.id) > --end > > Thanks, > > Abe > > > > On Fri, Jun 5, 2015 at 2:22 AM, Alexis BRENON <brenon.ale...@gmail.com> > wrote: > > Hi Abraham, > > I'm sorry, I don't understand what and when did commented out ? > > Can you please post your config file on pastebin (http://pastebin.com/) > or something like that (github?). > > > > To fix the error about 'insert' method, you can replace the line : > > notifications:insert(i, naughty.notify_(args,...)) > > by > > table.insert(notifications, i, naughty.notify) > > > > Maybe you will have also to cheat a little bit if i doesn't start to 1... > > > > Maybe I can explain you a little deeper what are the goals, this way you > will be able to debug yourself. > > > > So, you want to have your notifications displayed on many screens (the > exact number is not important). > > To do so, you have to redefine the classic naughty.notify function, to > call the initial naughty.notify function with the screen arg which loop > over all your screen. This is what is done by the code sent by Elv1313. > > > > Nevertheless, the initial notify function returns a table representing the > notification, containing for example an ID (the id field). If you don't > need it, so fine, stick to the Elv1313 solution and remove any > naughty.notify(...).id code in your config. > > But this ID can be useful if you need to replace a notification instead of > adding a new one (this can be the case if you use notification to display > volume changement, backlight modification, battery alert, whatever). > > To handle this, your new notify function must return the created > notifications, or at least their ID. > > This is what my code intend to do. For each call to the initial notify > function, I put the resulting table in a 'result' table, indexed by the > index of the screen on which the notification is displayed. Up to ypu after > to use it the right way. > > > > The last chunk of code I sent you, handle the case where you want to use > the replaces_id argument of notify. As, in your case, you will have not > only one, but many notifications to replace (one on each screen), you will > pass the replaces_id argument as a table. This is not handled by the > initial notify function, so for the actual call you use the value at the > index representing your screen, as we do for the 'screen' arg. > > > > I hope the reasonning is clear. > > > > Alexis > > > > Le ven. 5 juin 2015 à 05:13, Abraham Baker <z1693...@students.niu.edu> a > écrit : > > Hi, > > When I commented out 600 and 601 of naughty.lua *before* changing rc.lua, > I got: > > naughty.lua:604: bad arg #1 to 'ipairs' (table expected, got nil) > > on both screens. > > > > Then, when I added the updated naughy.notify function to rc.lua, I got: > > rc.lua:22 attempt to call a nil value (method 'insert') > > on only one screen > > Ironically, the previous solution would work perfectly if it wasn't for > the error messages (which are critical and have to be clicked away)! > > Is there a way to selectively silence the error messages related to > naughty.lua without silencing all errors? > > Thanks, > > Abe > > > > > > On Thu, Jun 4, 2015 at 2:08 AM, Alexis BRENON <brenon.ale...@gmail.com> > wrote: > > Hum, well, you will have to update a little bit your config! > > First, the default naughty.notify function returns a table representing > the notification, but your new notify function doesn't, so update it : > > > > naughty.notify_ = naughty.notify > > naughty.notify = function (args,...) > > notifications = {} > > for i = 1, screen.count() do > > args.screen = i > > notifications:insert(i, naughty.notify_(args,...)) > > end > > return notifications > > end > > > > Then line 600 you update to something like : > > local notifs = naughty.notify(args) > > local id = {} > > for notif in ipairs(notifs) do > > id:insert(notif.id) > > end > > > > Nevertheless, I think that you use the id value to replace the > notification, do you ? In this case, you will have to update again your > custom notification to handle the case if args.id is a table (instead of > a number) : > > > > naughty.notify = function (args,...) > > notifications = {} > > naughty_args = args > > for i = 1, screen.count() do > > if args.replaces_id and type(args.replaces_id) == "table" then > > naughty_args.replaces_id = args.replaces_id[i] > > end > > naughty_args.screen = i > > notifications:insert(i, naughty.notify_(args,...)) > > end > > return notifications > > end > > > > Or something like that. > > > > Cheers, > > Alexis > > > > Le mer. 3 juin 2015 à 22:30, Abraham Baker <z1693...@students.niu.edu> a > écrit : > > That actually works, but also generates an error (in the form of a > critical notification on both screens) at the same time: > > /usr/share/awesome/lib/naughty.lua:600: attempt to index a nil value > > For context, line 600 is: > local id = naughty.notify(args).id > > Looks like this is close to working right! Thanks! > > > > On Wed, Jun 3, 2015 at 2:24 PM, Elv1313 . <elv1...@gmail.com> wrote: > > This should help: > > local naughty = require('naughty') > naughty.notify_ = naughty.notify > naughty.notify = function (args,...) > for i = 1, screen.count() do > args.screen = i > naughty.notify_(args,...) > end > end > > > On 3 June 2015 at 10:42, Abraham Baker <z1693...@students.niu.edu> wrote: > > I tried adding that code right after the local naughty = > require("naughty") > > that was already there, but it didn't work and actually stopped any > > notifications from showing on any monitor. > > > > I doubt it was the cause, but some other functions in my rc.lua also use > > local i as a counter; these shouldn't interfere with each other as long > as > > they are inside their own functions, right? > > > > Thanks, > > Abe > > > > On Wed, Jun 3, 2015 at 8:20 AM, Alexis BRENON <brenon.ale...@gmail.com> > > wrote: > >> > >> Hi Abraham, > >> > >> you have to call the anughty.notift() function twice, once for each > >> screen. > >> Maybe you can define a function which do it for you : > >> > >> local naughty = require('naughty') > >> naughty.notify = function (args) > >> local i = 1 > >> while i <= screen.count() do > >> args.screen = i > >> naughty.notify(args) > >> end > >> end > >> > >> Or something like that > >> > >> Regards, > >> Alexis > >> > >> Le mer. 3 juin 2015 à 15:13, Abraham Baker <z1693...@students.niu.edu> > a > >> écrit : > >>> > >>> Hi, > >>> > >>> I have a standing/sitting monitor arrangement on my desk that makes it > >>> hard to see notifications on the upper monitor while sitting and vice > versa. > >>> I've been trying to change the default naughty config so notifications > >>> appear on both monitors at once, but so far I'm only able to just > change > >>> which monitor it shows up on (not both). > >>> > >>> Is there an easy way to have notifications shown on all monitors? > >>> > >>> Thanks, > >>> Abe Baker > > > > > > > > > > > >