Jérôme Belleman
Home  •  Tools  •  Posts  •  Talks  •  Travels  •  Graphics  •  About Me

Window Managers: Configuration Notes for Notion

5 Aug 2012

The holy grail of window managers, offering that level of configuration I'd always been seeking. Here are tips that were useful as I went along setting it up.

1 Resolve the Current Workspace

Get the current screen from the root window and get the current WMPlex from the current screen. Note that ioncore.rootwin() gets it right even with multiple screens:

local root = ioncore.rootwin() -- Yes, makes sense even with multiple heads
local scr = root:current_scr()
local ws = scr:mx_current()

2 Completion

Menus involving mod_query.query() need a completor implemented with a custom function which expects a string. This function typically returns the result from a call to mod_query.complete_name() which takes the string as first argument and a function a second.

While mod_query suggests the second argument should be an iterator, it's not an iterator in the sense it returns the next item in a list at each call; it's an iterator in the sense it calls the function it's given as argument for each argument – but it's called only once, and as such, it should loop through an array:

return mod_query.complete_name(str, function (fn)
                                        for i,v in ipairs(wswins) do
                                            fn(v)
                                        end
                                    end)

It took me a while to get that. Note that here, this argument function should be used to do something with the window; it probably involves calling v:name(), or something. None of this is documented, as far as I could see.

3 Command execution

While in many cases it may be a better idea to use ioncore.exec(), you may want to know about the os.execute() function described in the Lua 5.1 Reference Manual in order to spawn programs from Notion, either from key bindings or menus.

4 Debugging

While you can print debugging information with print(), you should know that you won't necessarily see it printed out to file even if you've had startx redirect everything to that file. Using io.stderr:write() or io.stdout:write() instead won't help either. A more successful way of dealing with this is to start Notion off a terminal and read what's written to stdout.

Also, because of the way Lua deals with library paths, it's convenient to copy e.g. modules from the system-wide installation into the ~/.notion directory to modify and understand them better.

5 References