Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd love to be able to set different backgrounds for different tabs in Awesome WM. Is there a way to do this?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You can add some code in your ~/.config/awesome/rc.lua file that will change the desktop wallpaper whenever you change tags. Technically, it will set the wallpaper to the tag you most recently selected (in awesome, you can have multiple tags selected at the same time).

If you don't have that file already, then copy the system-wide awesome config file into that location:

$ mkdir -p ~/.config/awesome
$ cp /etc/xdg/awesome/rc.lua ~/.config/awesome

In my rc.lua in Ubuntu 11.10, there is a section where the tags get created that is labeled like this:

-- {{{ Tags
-- {{{ Define a tag table which hold all screen tags.
[... code that creates default tags ...]
-- }}}

After that section, I added the following code:

-- {{{ Tag Wallpapers
for s = 1, screen.count() do
    for t = 1, 9 do
        tags[s][t]:add_signal("property::selected", function (tag)
            if not tag.selected then return end
            wallpaper_cmd = "awsetbg /home/user/Pictures/wallpaper" .. t .. ".png"
            awful.util.spawn(wallpaper_cmd)
        end)
    end
end
-- }}}

Replace "/home/user/Pictures" with the location you want to store your wallpapers. It will use the file "wallpaper1.png" for the 1st tag, "wallpaper2.png" for the 2nd, etc. Note that this assumes that you have 9 tags. If you have a different number, adjust the inner for loop.


awsetbg requires that you have some program installed capable of changing the wallpaper. For example, the 'feh' or 'imagemagick' packages. You can find a list of the supported programs in the awsetbg script (/usr/bin/awsetbg):

wpsetters="${wpsetters:=Esetroot habak feh hsetroot chbg fvwm-root imlibsetroot display qiv xv xsri xli xsetbg wmsetbg xsetroot}"

The only one my Ubuntu had installed by default was xsetroot, but I believe that program only supports bitmap images. I have imagemagick installed (provides the 'display' command), so that can handle most any format you can imagine. ;)


If you are using a gnome/awesome hybrid desktop (using gnome with awesome as the window manager) and haven't disabled nautilus's desktop management, you may have to use the gnome method of setting the wallpaper instead of awsetbg. This is because nautilus manages the desktop and may override your settings. For 11.10, you would change the awsetbg command to:

gsettings set org.gnome.desktop.background picture-uri file:///home/user/Pictures/wallpaper1.png

gsettings is the new way, for older Ubuntu versions (not sure exactly how long ago it changed), you should use gconftool-2:

gconftool-2 --set /desktop/gnome/background/picture_filename --type string file:///home/user/Pictures/wallpaper1.png
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.