1

A similar question, (How do I change the Desktop wallpaper from the cli), was asked previously where the person wanted to know how to change the wallpaper.

Going through the answers, I discovered that there is a file,

/home/pi/.config/pcmanfm/LXDE-pi/desktop-items-0.conf

In my case it contains the line desktop_bg=#7f7f7f7f7f7f which represents a medium grey desktop. (I've turned the wallpapers off).

What I want to do is change that background color to a different one programmatically, such that the original color will return when rebooted.

I have a Raspberry Pi that is running off of an external battery and I have a program, (that already works), that measures the battery's voltage and - when it drops below a certain point - displays a warning message and then still later, if the voltage has dropped near the point where the battery will shut itself off, it commands a system shutdown.

What I want to do is - when the battery voltage drops to the "warning voltage" - have my battery monitor program change the desktop's background to red. Ideally, this would persist until the next reboot whereupon the desktop background would return to the previously set color.

I can change the desktop_bg value in the file and save it. The next time I open the desktop preferences, I see the new color selected and when I click "OK", the new color is set.

What I want to know is how to set the color on demand without having to use the desktop preferences dialog.

MatsK
  • 2,882
  • 3
  • 17
  • 22

1 Answers1

0

Which version of Raspberry Pi OS? Which desktop environment are you using? Can't you just set a red image as your new background? That should be quite easy to do if you follow the documentation of your used desktop environment.

Then also just make a script that sets the background back to the default image, after each login (with rc.local or maybe even cron for example)

EDITTED MY ANSWER BASED ON YOUR COMMENT:

Could've guessed your OS from the original post (since you describe a path to LXDE).

The default Raspberry Pi OS uses a modified version of LXDE as desktop environment with Openbox stacking window manager, along with a unique theme.

Searching for lxde set desktop image on Google, gives a couple results you could try (also from RaspberrPi StackExchange, so this question is a duplicate): Change wallpaper in LXDE through terminal

They have discussed this problem, and debugged quite a few possible solutions.
Please mark as duplicate or solved if this helped you :)

Mats de Waard
  • 128
  • 10