Background
I have a small script that changes my wallpaper to a random image:
#!/bin/bash
feh --randomize --bg-fill /home/USERNAME/Pictures/wallpapers/*
It works like a charm, so I decided to add it to the startup applications, like in this question:
Problem
Everything works fine except for one problem:
- On start up, the wallpaper is changed via the script, as expected. Then, seconds after, Ubuntu takes over and replaces that wallpaper with the default one.
Question
How can I keep this from happening?
Why Wallpaper is Replaced
Long story short, when you have desktop icons enabled, that essentially enables Nautilus to create the Desktop "window" with all the file and folder icons and manage background.
feh
works with rawX11
desktop, i.e. bare bones, where no icons exist. So there's two potential solutions: one is to rely on Ubuntu's settings for background, or two - disable desktop icons. One can also make a script to launch bothfeh
and alter Ubuntu desktop settings, but that's redundant in my opinion. Whichever way you decide to go is up to youDisabling/Enabling icons
This can be done via
gsettings org.gnome.desktop.background show-desktop-icons false
to disable andorg.gnome.desktop.background show-desktop-icons true
to enable. Once that's done Nautilus won't manage your desktop, hence won't set the background pictureUbuntu Wallpaper Settings
Aside from obvious GUI methods, one can use
gsettings
command to set the wallpaper.Of course, previously mentioned caveat applies - the desktop icons have to be enabled.
Alternative to Your Script
I have noticed that you are trying to set a random wallpaper from a folder. You don't have to rely on
feh
for that. In the past, I've written two scripts to do this task. One written as bash script and another one as Python script. Both scripts work with Ubuntu'sgsettings
and alter the desktop wallpaper without disabling icons. Personally, I'd suggest the Python one as it is more polished.