Okay, after viewing several man pages, forums, web pages, help files, and so forth and not finding the answer I was looking for, I’m posting this here.
I migrated over from GNOME, and already wrote a script using the command “gsettings set org.gnome.desktop.background primary-color <#RRGGBB>” to set the background color, in my case as a login script and set it depending on the day of the week. However I found with version 42 GNOME ended this ability, which prompted a search for an alternative DE, and I wound up landing on LXQt, used by Lubuntu.
I found the background color value is stored in /home//.config/pcmanfm-qt/lxqt/settings.conf and in fact is the first value in the [Desktop] section.
I also know if I right click on the desktop and choose “Desktop Preferences” I can manually set the background color. I also found typing “pcmanfm-qt --desktop-pref desktop perferences” will bring up the popup that allows for changing the background color. So obviously some kind of code to do this exists. But so far, I’ve been unable to uncover what command to give what module.
In summary, does anybody know how to set the desktop background color from the command line for Lubuntu 22.04?
You’ve done your homework well sofar. I guess that not many people require direct command line access to your requested feature, so probably it doesn’t exist. The easiest and quickest way around this is just to let sed do the job.
sed is part of the suite of simple but very efficient Linux command line tools, which form together a true Swiss knife. It is mostly used for simple changes in existing text files, and ideal for scripting. If you need help, please let me know.
Here’s a hacky way to do it during login, although there is a bit of a delay.
Create this script and put it somewhere;
e.g wallpaper.sh (make sure it’s executable)
#!/bin/bash
T=$(date +"%H%M")
if [ "$T" -lt "1900" ]; then
pcmanfm-qt -w $HOME/Pictures/wallpapers/day.jpg
else
pcmanfm-qt -w $HOME/Pictures/wallpapers/night.png
fi
Preferences > LXQt Settings > Session Settings > Autostart
2a. Click once LXQT Autostart. Then Add.
Name: Change Wallpaper
Command: for the script above.
Wait for system tray : Yes
OK
Edit /.config/autostart/lxqt-desktop.desktop
and change Exec=pcmanfm-qt --desktop --profile=lxqt
to Exec=pcmanfm-qt --desktop --profile=lxqt -w /dev/null
(this will blank out the previous desktop so that it won’t flash during login).
Perhaps humpty’s solution. it is not exactly what zon14 wants. His use case is to have a different background colour every time the day changes on a running system. And not a different wallpaper image when the login is after an arbitrary moment.
It is possible to have a plain colour on your desktop (instead of an(y) image). The configuration wizard has rudimentary support for that in the background tab: 1) select a colour; 2) introduce a non-existing pathname for the (non-required) wallpaper file. Strange, but this is the way it works (in lxqt 0.16.0).
The actual value of the colour for the background is stored in a configuration file, which can be easily modified with e.g. sed in a bash script file which is triggered with cron.
I’ll only have to find out in which file the information is stored
Yeah. sed would be useful for writing to the config file, but would require a restart of pcmanfm-qt. I had one other idea. Is there a scripting command the equivalent of Windows sendkeys? I’ve already proven to myself I can open the change background color dialog. It’d be sending a bunch of tabs and returns first, then overwriting the box with the color value, then returning over Okay, okay, etc. That would work, if it’s available.