You are not logged in.

#1 Yesterday 14:23:45

MAYBL8
Member
From: Florida USA
Registered: 2022-01-14
Posts: 397
Website

trying to script kde plasma wallpaper settings

I will attach the script i am trying to do.
It  is setting the dir but it is not showing images in the preview box and not setting the interval to change the wallpaper.
I used duckduckgo AI to help write the script but it couldn't get me any further.
I was hoping someone here could help.

#!/usr/bin/env bash
set -euo pipefail
WALLPAPER_DIR="${HOME}/.config/variety/Downloaded"
INTERVAL_SECONDS=300
if [[ ! -d "$WALLPAPER_DIR" ]]; then
echo "Directory not found: $WALLPAPER_DIR" >&2
exit 1
fi
SAMPLE_IMAGE=$(find "$WALLPAPER_DIR" -maxdepth 2 -type f -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' | head -n1 || true)
if [[ -z "$SAMPLE_IMAGE" ]]; then
echo "No images found under: $WALLPAPER_DIR" >&2
exit 1
fi
WALLPAPER_URI="file://${WALLPAPER_DIR%/}"
SAMPLE_IMAGE_URI="file://${SAMPLE_IMAGE}"
INTERVAL_MS=$((INTERVAL_SECONDS * 1000))

JS='var all = desktops(); for (var i = 0; i < all.length; i++) { var d = all[i]; d.wallpaperPlugin = "org.kde.slideshow"; d.currentConfigGroup = ["Wallpaper","org.kde.slideshow","General"]; d.writeConfig("SlidePaths", ["'"$WALLPAPER_URI"'"]); d.writeConfig("Recursive", 1); d.writeConfig("Interval", '"$INTERVAL_MS"'); d.writeConfig("Image", "'"$SAMPLE_IMAGE_URI"'"); }'
qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "$(printf '%s' "$JS")"

killall plasmashell || true
kstart5 plasmashell &>/dev/null || true

echo "Set slideshow wallpaper folder to: $WALLPAPER_DIR"
echo "Sample image: $SAMPLE_IMAGE"
echo "Interval: ${INTERVAL_SECONDS}s"

Offline

#2 Today 15:53:18

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,583

Re: trying to script kde plasma wallpaper settings

This is just a heads up, It's not that I'm going to solve that fugly script for you, but did you actually (try and) read it and did it make sense??
My advice don't let AI make your scripts for you if you're unable yourself to verify and check it's output...
One thing I noticed 'qdbus' what is that?, btw that whole loop looks needlessly complicated.
Another thing, are you sure time is stored in milliseconds otherwise 300 * 1000 = 300000 seconds that's a few days
I'd be amazed if anyone's going to solve this for you, go and make something yourself chances are a lot better in that case!
And throw this thing away wink

Offline

#3 Today 20:05:41

MAYBL8
Member
From: Florida USA
Registered: 2022-01-14
Posts: 397
Website

Re: trying to script kde plasma wallpaper settings

Thanks for the help and words of encouragement .

Offline

Board footer

Powered by FluxBB