Skip to content

Instantly share code, notes, and snippets.

@cmj
Last active May 14, 2025 06:09
Show Gist options
  • Save cmj/a0d7ed9bdd5a04ae41d986c814895284 to your computer and use it in GitHub Desktop.
Save cmj/a0d7ed9bdd5a04ae41d986c814895284 to your computer and use it in GitHub Desktop.
Set KDE Plasma desktop wallpaper
#!/bin/bash
# Set KDE Plasma desktop (and X11 for legacy apps) wallpaper
image=$1
usage() { echo -e "Set KDE wallpaper:\n${0##*/} <image_file>"; exit 1; }
[ ! "$*" ] || [ ! -f "$image" ] && usage
[ "$image" != "${1#/}" ] || image="$PWD/$1"
# set x11 root first
#hsetroot -full "${image}" -tint \#999999
hsetroot -cover "${image}"
# set plasma
qdbus6 org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file://${image}\")}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment