50 lines
1.8 KiB
Bash
Executable File
50 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
|
|
BUILD_DIR=${BUILD_DIR:-"$ROOT/build"}
|
|
PACKAGE_ID=dev.emil.lumen
|
|
|
|
for command_name in busctl plasmashell nohup; do
|
|
command -v "$command_name" >/dev/null 2>&1 || {
|
|
printf 'Lumen activation: missing command: %s\n' "$command_name" >&2
|
|
exit 1
|
|
}
|
|
done
|
|
if ! busctl --user call org.kde.plasmashell /PlasmaShell \
|
|
org.kde.PlasmaShell wallpaper u 0 >/dev/null 2>&1; then
|
|
printf 'Lumen activation: no running Plasma session was found\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
BACKUP_DIR="$BUILD_DIR/activation-backup-$(date +%Y%m%d-%H%M%S)-$$"
|
|
mkdir -p "$BACKUP_DIR" "$HOME/.config/plasma-workspace/env"
|
|
: > "$BACKUP_DIR/wallpaper-plugins.txt"
|
|
for ((screen = 0; ; ++screen)); do
|
|
if ! description=$(busctl --user call org.kde.plasmashell /PlasmaShell \
|
|
org.kde.PlasmaShell wallpaper u "$screen" 2>/dev/null); then
|
|
break
|
|
fi
|
|
printf '%s\n' "$description" > "$BACKUP_DIR/wallpaper-screen-$screen.txt"
|
|
if [[ $description =~ \"wallpaperPlugin\"\ s\ \"([^\"]+)\" ]]; then
|
|
printf '%d %s\n' "$screen" "${BASH_REMATCH[1]}" \
|
|
>> "$BACKUP_DIR/wallpaper-plugins.txt"
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
if [[ ! -s "$BACKUP_DIR/wallpaper-plugins.txt" ]]; then
|
|
printf 'Lumen activation: could not back up the current wallpaper plugins\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
printf '%s\n' 'export QSG_RHI_BACKEND=vulkan' \
|
|
> "$HOME/.config/plasma-workspace/env/lumen-vulkan.sh"
|
|
|
|
busctl --user call org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell evaluateScript s \
|
|
"desktops().forEach(function(d) { d.wallpaperPlugin = '$PACKAGE_ID'; });"
|
|
|
|
QSG_RHI_BACKEND=vulkan nohup plasmashell --replace \
|
|
> "$BACKUP_DIR/plasmashell.log" 2>&1 &
|
|
printf 'Lumen Wallpaper activated. Backup: %s\n' "$BACKUP_DIR"
|