0

I made a change in my rc.lua to always open Chromium on screen 2:

awful.rules.rules = {
    -- many other rules here...

    -- Set Chromium to always map on screen "2"
    { rule = { class = "Chromium" },
      properties = { screen = 2 } },
}

However, when I do not have an external monitor attached, I get an error ("screen expected, got nil"). How do I modify this rule to use screen 1 if screen 2 is not available?

mbork
  • 564
  • 3
  • 23

1 Answers1

2

The following assumes you have only two or one screens. It does the wrong thing when there are more screens, but it should get the idea across:

properties = { screen = function() return screen.count() end }

All(?) properties in awful.rules can also be specified as a callback function. This function even gets the client (and the table of collected properties?) as argument (but this is not used in this example).

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • Thanks, that's great! I was sure something like that would exist, I just didn't know the interface. – mbork Apr 27 '20 at 21:02