Sunday, September 25, 2011

Set wallpaper in xfce4 from command line.

With so many folks switching to xfce4 desktop from gnome or kde, thought I'd post this little bash function for setting the wallpaper.

set_wallpaper()
{
  # Set picture $1 as desktop background
  # 0 - Auto
  # 1 - Centered
  # 2 - Tiled
  # 3 - Stretched
  # 4 - Scaled
  # 5 - Zoomed
  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s $1
  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-style -s 4
  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-show -s false
  xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-show -s true
}


The last two xfconf-query commands seem to be needed to get the screen to refresh.

Labels: , ,