Bug 487816 - Make it easier for distributions to customize the default wallpaper
Summary: Make it easier for distributions to customize the default wallpaper
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Image Wallpaper (show other bugs)
Version: 6.0.5
Platform: postmarketOS Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-30 20:57 UTC by Oliver Smith
Modified: 2024-06-11 19:51 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Smith 2024-05-30 20:57:07 UTC
There is no clean way to change the default wallpaper for distributions.

It would be great if there was a simple config file that the distribution could write, which would then set a different wallpaper as default. (The default wallpaper of Plasma 6 is really beautiful, but we are looking into setting a consistent wallpaper across all UIs in postmarketOS, and changing it with every release.)

For example, with GNOME this can be done by writing a file like this to /usr/share/glib-2.0/schemas/10_pmOS-wallpaper.gschema.override:

[org.gnome.desktop.background]
picture-uri='file:///usr/share/wallpapers/postmarketos/contents/images/2707x2707.png'
picture-uri-dark='file:///usr/share/wallpapers/postmarketos/contents/images_dark/2707x2707.png'

Doing it for Plasma only seems to work by talking to the D-Bus API within a running Plasma session. I've done it via the following hack for now:

1. Write to /etc/skel/.config/autostart/set-plasma-wallpaper.desktop:

[Desktop Entry]
Exec=/usr/libexec/postmarketos/set-plasma-wallpaper.sh
Name=Set postmarketOS Wallpaper for Plasma
Terminal=False
Type=Application

2. Write to /usr/libexec/postmarketos/set-plasma-wallpaper.sh:

#!/bin/sh
MARKER=~/.local/state/postmarketos/plasma-wallpaper-has-been-set
WALLPAPER_PATH="/usr/share/wallpapers/postmarketos"

# Only run this script in Plasma sessions. This variable is set in in both
# Plasma Desktop and Plasma Mobile (unlike e.g. XDG_DESKTOP_SESSION).
if [ -z "$KDE_FULL_SESSION" ]; then
	exit 1
fi

# Only run this script once. If the user selects a different wallpaper
# afterwards, it should not be changed.
if [ -e "$MARKER" ]; then
	exit 0
fi

echo "set-plasma-wallpaper: changing to: $WALLPAPER_PATH"

# Unfortunately this fails if the D-Bus API isn't available yet. So we have to
# try multiple times.
for i in $(seq 1 30); do
	sleep 1

	if ! plasma-apply-wallpaperimage "$WALLPAPER_PATH"; then
		continue
	fi

	mkdir -p "$(dirname "$MARKER")"
	touch "$MARKER"
	echo "set-plasma-wallpaper: success"
	exit 0
done

echo "set-plasma-wallpaper: failed"
exit 1
Comment 1 Niccolò Venerandi 2024-05-31 09:00:38 UTC
The wallpaper is read in the `plasma-org.kde.plasma.desktop-appletsrc` file:

```
[Containments][1][Wallpaper][org.kde.image][General]
Image=/home/niccolove/Nextcloud/Photos/Wallpapers/IMG_1618.png
```

each containment (e.g. monitor) has its own entry, so that different containments can have different wallpapers. There's a setup script, called 'org.kde.plasma.desktop-layout.js', that's part of the global theme and that an set this kind of things automatically:

```
var desktopsArray = desktopsForActivity(currentActivity());
for( var j = 0; j < desktopsArray.length; j++) {
    desktopsArray[j].wallpaperPlugin = 'org.kde.image';
}
```

you can add:

```
    desk = desktopsArray[j];
    desk.currentConfigGroup = new Array("Wallpaper","org.kde.image","General");
    desk.writeConfig("Image", "/usr/share/something/");
```

I guess the correct way to do this would be to create a new look and feel theme that inherits anything from the Beeze one but only changes the wallpaper in the above script. However I never tried this.

Does this help?
Comment 2 Oliver Smith 2024-06-02 16:45:14 UTC
(In reply to Niccolò Venerandi from comment #1)
> The wallpaper is read in the `plasma-org.kde.plasma.desktop-appletsrc` file:
> 
> ```
> [Containments][1][Wallpaper][org.kde.image][General]
> Image=/home/niccolove/Nextcloud/Photos/Wallpapers/IMG_1618.png
> ```

Right, I found that as well. I have also tried just installing a `plasma-org.kde.plasma.desktop-appletsrc` via /etc/skel and set the wallpaper there, but that didn't work either (and of course that wouldn't be a great solution either).

> 
> each containment (e.g. monitor) has its own entry, so that different
> containments can have different wallpapers. There's a setup script, called
> 'org.kde.plasma.desktop-layout.js', that's part of the global theme and that
> an set this kind of things automatically:
> 
> ```
> var desktopsArray = desktopsForActivity(currentActivity());
> for( var j = 0; j < desktopsArray.length; j++) {
>     desktopsArray[j].wallpaperPlugin = 'org.kde.image';
> }
> ```
> 
> you can add:
> 
> ```
>     desk = desktopsArray[j];
>     desk.currentConfigGroup = new
> Array("Wallpaper","org.kde.image","General");
>     desk.writeConfig("Image", "/usr/share/something/");
> ```
> 
> I guess the correct way to do this would be to create a new look and feel
> theme that inherits anything from the Beeze one but only changes the
> wallpaper in the above script. However I never tried this.
> 
> Does this help?

Thanks for describing how it works, appreciate the effort you put into this reply!

Unfortunately it doesn't really help however. The proposal here is at least as complex, but untested, as the tested workaround I already have (writing that JS file, writing a custom theme that inherits things from Breeze and then somehow setting that theme as default).

This issue is about dramatically reducing the complexity to set a wallpaper with e.g. a simple config file as written in the top post.
Comment 3 Marco Martin 2024-06-06 14:15:52 UTC
the recommended way is doing a look and feel package, which could also customize other things, like color and what not, but it's alright if it just sets the wallpaper
Comment 4 Oliver Smith 2024-06-09 17:00:57 UTC
(In reply to Marco Martin from comment #3)
> the recommended way is doing a look and feel package, which could also
> customize other things, like color and what not, but it's alright if it just
> sets the wallpaper

Thanks for the reply!

Could you give me pointers to:
* how distributions should set a custom look and feel package as default
* how one would create such a look and feel package
Comment 5 Nate Graham 2024-06-11 19:51:39 UTC
Yeah, making a Global Theme for this is generally what distros do, but it's heavyweight and results in unnecessary noise in the Global Themes KCM. I think it's a legitimate complaint with room for improvement.

If we do insist on keeping this, we need to document it much better and also probably add a method to hide the theme from the KCM since it's just an implementation detail.