XRandR Screen Table

From awesome
Jump to: navigation, search

XRandR Screen Table

This small function can be used to address screens by their XRandR names instead of numbers. First call XrandR before starting awesome, i.e. put the next line in your .xinitrc file before the line that says exec awesome:

xrandr -q >/home/youruser/.config/awesome/xrandrtable

Then paste the function into your rc.lua.

function xrandr_screens ()
    local screens = {}
    local counter = 1
    local handle = io.popen("cat /home/youruser/.config/awesome/xrandrtable")
    for display in handle:read("*all"):gmatch("([%a%d-]+) connected") do
        screens[display] = counter
        counter = counter + 1
    end
    handle:close()
    return screens
end


Then use it like this, for example:

screens = xrandr_screens()
client.focus.screen = screens["VGA"]

Please note that this function needs the xrandr tool installed.

Personal tools