1

For background, I'm currently using notify-send to produce dbus notifications when a long script finishes but I'd like to make better notifications with naughty.

I found this simple script https://gist.github.com/lgaggini/51a35f363b7f1966971e869f3fbb5335 for sending naughty notifications using awesome-client. It initializes the naughty library every time it runs, which seems messy since it only needs to be loaded once per session.

In my rc.lua, I tried changing the line

local naughty=require("naughty")

  1. remove local: still needed to require naughty through a lua prompt or awesome-client after restarting awesome
  2. add global: that's not actually a keyword in lua so it breaks my config

Is there something I can do here or elsewhere in my rc.lua that will make this (or any other) library available to awesome-client without an extra step?

fredwhy
  • 13
  • 3
  • 2
    I'm not running awesome, but if the Lua state itself persists (which (I think) is a prerequisite for you to pre-load the library just once), then you probably don't need to do anything at all. [`require`](https://www.lua.org/manual/5.3/manual.html#pdf-require) caches loaded modules, so it won't actually load things again and again, just grab a reference to the module from another table (namely, [`package.loaded`](https://www.lua.org/manual/5.3/manual.html#pdf-package.loaded)). – nobody Sep 19 '17 at 23:33
  • @nobody I'd claim that you just answered the question. Also, just removing the `local` should definitely work. – Uli Schlachter Sep 21 '17 at 16:51
  • You're both right, I don't know what I was messing up but removing `local` does work. I'm going to delete this since it was such a useless question - unless there's a different convention I should follow? – fredwhy Sep 22 '17 at 18:38

0 Answers0