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:
local function set_d_wallpaper()
themes_path = gears.filesystem.get_configuration_dir() .. "themes/dualhead/"
d_wallpaper = themes_path .. "right.jpg"
gears.wallpaper.maximized(d_wallpaper, 1, true)
d_wallpaper = themes_path .. "left.jpg"
gears.wallpaper.maximized(d_wallpaper, 2, true)
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.