3

I would like to change the wallpaper (to a specific file using its full path) on linux from a shell/bash script.

I already found several approaches (see below) to do that - but those dont work on all desktop environments.

a) Using gnome-settings-daemon / gsettings:

gsettings set org.gnome.desktop.background picture-uri   file://$fullPathToMyImage

b) using gconftool-2

gconftool-2 --type=string --set /desktop/gnome/background/picture_filename $fullPathToMyImage

c) using feh

feh --bg-scale $fullPathToMyImage

I am now searching for additional methods (while Gnome seems covered with a, b and c) - preferable for all desktop environments (and all linux distributions).

So far i am at least missing methods for KDE4/5 and XFCE

Similar post: Shell script changing desktop wallpaper

Community
  • 1
  • 1
dufte
  • 249
  • 1
  • 4
  • 16
  • 1
    I assume you realize this, but there isn't going to be any single method for all desktop environments (although you can certainly cover most of the major ones). – forkrul Dec 14 '15 at 14:11
  • @forkrul: yes i assumed that already - but thanks for pointing it out ;). I just hope to collect/know/find all major ones to provide a good solution in some kind of case statement in my script – dufte Dec 14 '15 at 14:14

1 Answers1

0

As for xfce you can use this command:

 xfconf-query -c xfce4-desktop -p $xfce_desktop_prop_prefix/workspace1/last-image -s /path/to/file

And also useful set image as zoomed for example

xfconf-query -c xfce4-desktop -p $xfce_desktop_prop_prefix/workspace1/image-style -s 5

You can see how I did it in my script - https://github.com/yatsenko-ihor/himawari8-wallaper/blob/master/himawari8_wallaper.sh

  • Thanks for the input. Results for me in the following output: Property "/workspace1/last-image" does not exist on channel "xfce4-desktop". If a new property should be created, use the --create option. – dufte Feb 20 '16 at 19:30