Based on the answer by crater2150 I found a working solution. I post this in case anyone has the same problem.
-- set up keybindings based on existing monitors
for s in screen do
for screen_name, _ in pairs(s.outputs) do
if screen_name == "eDP-1" then
globalkeys = awful.util.table.join(globalkeys,
awful.key({modkey}, "F1", function() awful.screen.focus(s) end))
elseif screen_name == "DP-2-2" then
globalkeys = awful.util.table.join(globalkeys,
awful.key({modkey}, "F2", function() awful.screen.focus(s) end))
elseif screen_name == "DP-1-2" then
globalkeys = awful.util.table.join(globalkeys,
awful.key({modkey}, "F3", function() awful.screen.focus(s) end))
end
end
end
Simply iterate over all screens and if the ones you are interested in exist, add a keybind that switches to the respective screen.
outputs
property? I triedproperty::outputs.name['DP-1-2']
which does not seem to work. – user346830 Apr 12 '19 at 10:56outputs
is a bit misleading, there is noname
attribute on it, you have to replace it with the actual name. You also cannot get a screen object from it directly. I've expanded the answer a bit to show how you could use it. – crater2150 Apr 13 '19 at 07:53bad argument #1 to 'pairs' table expected, got userdata
"). I tried several variations likes.name
,s.outputs.name
andscreen.outputs.name
because according to the docsoutputs
should have a table calledname
which includes the screens as keys. As you said the docs seem a bit misleading as neither of the above worked. – user346830 Apr 15 '19 at 07:37