main/postmarketos-artwork: set plasma wallpaper (MR 5186)

Set the postmarketOS wallpaper as default for Plasma Mobile and Plasma
Desktop, so we can change it across all UIs with every postmarketOS
release.

It would be nice if we could just set the wallpaper with a simple config
file (reported https://bugs.kde.org/show_bug.cgi?id=487816). Until that
is possible, use a shell script as workaround.

Copy the contents dir and metadata.json file explicitly, instead of
copying the entire "meadow" directory. With this change we avoid copying
meadow.svg, which fixes two issues:
* This file doesn't have a stable name, when we switch to the next
  wallpaper and the user had selected it, the wallpaper will just be
  gone instead of automatically switching to the new wallpaper.
* It shows up as broken wallpaper in Plasma's wallpaper selection.

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Oliver Smith 2024-05-30 20:57:46 +02:00
parent 06f761e972
commit 0059607677
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 65 additions and 4 deletions

View file

@ -1,7 +1,7 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
pkgname=postmarketos-artwork
pkgver=5
pkgrel=2
pkgrel=3
pkgdesc="Meta package for the postmarketOS artwork"
url="https://postmarketos.org/"
arch="noarch"
@ -10,11 +10,14 @@ _hash="f28dd5fef287c970f50ca49bc44814ee1e3b229d"
source="postmarketos-artwork-$_hash.tar.gz::https://gitlab.com/postmarketOS/artwork/-/archive/$_hash/artwork-$_hash.tar.gz
10_pmOS-wallpaper.gschema.override
postmarketos-gnome.xml
set-plasma-wallpaper.desktop
set-plasma-wallpaper.sh
"
subpackages="
$pkgname-wallpapers
$pkgname-wallpapers-extra:wallpapers_extra
$pkgname-wallpapers-gnome:wallpapers_gnome
$pkgname-wallpapers-plasma:wallpapers_plasma
$pkgname-icons
$pkgname-sounds
"
@ -32,7 +35,7 @@ package() {
wallpapers() {
pkgdesc="Wallpapers for postmarketOS"
mkdir -p "$subpkgdir"/usr/share/wallpapers
mkdir -p "$subpkgdir"/usr/share/wallpapers/postmarketos
# To avoid complexity, we only package the most recent wallpaper.
# Checklist for changing the wallpaper:
@ -43,8 +46,10 @@ wallpapers() {
# - postmarketos.jpg symlink/conversion below
# - postmarketos-gnome.xml
# - 10_pmOS-wallpaper.gschema.override
cp -r "$builddir"/wallpapers/2024/meadow \
"$subpkgdir"/usr/share/wallpapers/postmarketos
for i in contents metadata.json; do
cp -r "$builddir"/wallpapers/2024/meadow/"$i" \
"$subpkgdir"/usr/share/wallpapers/postmarketos/"$i"
done
# /usr/share/wallpapers/postmarketos.jpg should always point to the
# current wallpaper so we don't break configs
@ -82,6 +87,17 @@ wallpapers_gnome() {
-t "$subpkgdir"/usr/share/glib-2.0/schemas
}
wallpapers_plasma() {
pkgdesc="Wallpaper configuration for Plasma-based UIs"
install_if="postmarketos-artwork-wallpapers=$pkgver-r$pkgrel postmarketos-base-ui-plasma"
install -Dm755 "$srcdir"/set-plasma-wallpaper.sh \
-t "$subpkgdir"/usr/libexec/postmarketos
install -Dm644 "$srcdir"/set-plasma-wallpaper.desktop \
-t "$subpkgdir"/etc/skel/.config/autostart
}
icons() {
pkgdesc="Icons for postmarketOS"
@ -107,4 +123,6 @@ sha512sums="
cef2326a28dbd597f3d679329aaac17031bf1fdc60f634bc25cf20b23e62028961c5f228570df824615b21616a18ab2fd290a770cfd4f3ca1d929ac552a34ea8 postmarketos-artwork-f28dd5fef287c970f50ca49bc44814ee1e3b229d.tar.gz
6464a9246d1c9cac5cd2f55345f1659e872377f941160132c897c8c08955bb61083fec6daa8993a34bffdcc900a29f7ae6438fe86a476242447ddccf4e937d06 10_pmOS-wallpaper.gschema.override
0bcdfb41adb02b657ee0f9938d134d551fa8c3ef166e8a7895908d1dd355119143088641196505b3e2018896ae39a5392032de114aa602f4911b3aeadddd7b60 postmarketos-gnome.xml
a2fe87907a0fc6eb2b18305c7f183ac57bae7223d9fdeb992c93947576480c6a2fdb073ea2746407e227531c84aaa0acd0c27abb7fb272bc58433b3a02c260f4 set-plasma-wallpaper.desktop
770bf87c4629327b4c7b35ee42587cdcd6100103640cce1894be66d1346b7220df919371935f3288e00f99b652f223ad578f1e93c5d43556e7c4ddd50f87f739 set-plasma-wallpaper.sh
"

View file

@ -0,0 +1,5 @@
[Desktop Entry]
Exec=/usr/libexec/postmarketos/set-plasma-wallpaper.sh
Name=Set postmarketOS wallpaper for Plasma
Terminal=False
Type=Application

View file

@ -0,0 +1,38 @@
#!/bin/sh
# Set the postmarketOS wallpaper in Plasma based UIs. Replace this hack when we
# have a cleaner method: https://bugs.kde.org/show_bug.cgi?id=487816
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