Useful snippets #3: dual wallpapers on Awesome window manager

The main configuration file of Awesome wm is ~/.config/awesome/rc.lua. The default function in rc.lua on multihead systems is to install the same, maximized, theme.lua-defined wallpaper to all screens. That is all well, if a) you really want the same wallpaper on all screens, and b) if all of your screens are of the same aspect ratio. But if, for example, your main screen is 16:9 and secondary 4:3, or, like in my case, the secondary screen is in portrait mode, the default function creates a mess.

I didn’t find any example code anywhere, so I had to figure it out for myself. This is the lua code I ended up with:

  1. local function set_d_wallpaper()
  2.     themes_path = gears.filesystem.get_configuration_dir() .. "themes/dualhead/"
  3.     d_wallpaper = themes_path .. "right.jpg"
  4.     gears.wallpaper.maximized(d_wallpaper, 1, true)
  5.     d_wallpaper = themes_path .. "left.jpg"
  6.     gears.wallpaper.maximized(d_wallpaper, 2, true)
  7. end

Insert it after the original set_wallpaper(s)-function in rc.lua. After that, edit the two calls to set_wallpaper() below it to use set_d_wallpaper() instead. In my case, the secondary screen is to the left of the main screen, so adjust the above code accordingly to suit your layout.

This entry was posted in Linux and tagged , , , . Bookmark the permalink.