I’m using an
xrandr
script to set screen size and rotation. In this case one screen is in landscape mode and the other is rotated. How can I detect this rotation in the Awesome WM configuration?The goal is to set the tag layout so that the windows are divided along the short axis of the screen. That is, a tag which uses
awful.layout.suit.tile
in landscape mode would useawful.layout.suit.tile.bottom
in portrait mode. That is, rather than this:
I want this:
Answer
Today this is rather easy. Assuming you have the following layouts defined in your rc.lua
:
awful.layout.layouts = {
awful.layout.suit.tile,
awful.layout.suit.tile.bottom,
}
With awful.screen.connect_for_each_screen(func)
you can call a function for each existing and created-in-the-future screen. It is very likely you have such a call in your rc.lua
already (for example to set the wallpaper or create tags). Depending on your configuration you need something like this:
awful.screen.connect_for_each_screen(function(s)
if s.geometry.width >= s.geometry.height then
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[1])
else
awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[2])
end
end)
Attribution
Source : Link , Question Author : l0b0 , Answer Author : ploth