Is it possible to create a script which will change a wallpaper picture?

I need a script (maybe python or bash or any else, doesn’t matter) which will change a wallpaper. I haven’t find literally anything in the internet, that’s why i’m here :confused:

I don’t know is it important but i’m using plasma gui
ls /usr/bin/*session output:

/usr/bin/dbus-run-session  /usr/bin/pipewire-media-session  /usr/bin/plasma_session

So, is it possible to make such script? (it should be a single file)

Not really what you’re asking, but Plasma does allow for wallpaper slideshows out-of-the-box.

Right-click the desktop and choose “Configure Desktop and Wallpaper”. There, you can select different types of wallpaper, such as “Image”, “Slide Show”, et al. You can also get new plugins for handling wallpapers. :arrow_down:

3 Likes

You can make a bash script and use feh to change wallpaper. This script changes the wallpaper every 5 seconds. Change the directory as you like.

#!/bin/bash

for i in {1..10}
do
	feh --bg-fill --randomize /usr/share/backgrounds/xfce/*
	sleep 5
done

here is my bash script that downloads a random bing wallpaper from a random bing marketplace and the last 7 days and applies it to desktop

#!/bin/bash
a='https://www.bing.com/HPImageArchive.aspx?format=js&idx='
b=$(( RANDOM % 8 ))
c=( zh-CN en-US ja-JP en-AU en-UK de-DE en-NZ en-CA )
d="&n=1&mkt="
e=${c[RANDOM%${#c[@]}]}
file="/tmp/wallcomb"
l=$(tail -c 2 /tmp/wallcomb) 

while grep -q "$e$b" $file >/dev/null 2>&1 || [ "$l" = "$b" ] ;
do
b=$(( RANDOM % 8 ))
e=${c[RANDOM%${#c[@]}]}
l=$(tail -c 2 /tmp/wallcomb) 
done

json=$(curl $a$b$d$e)
wait
finalurl1="https://www.bing.com"
finalurl2="$(echo "$json" | grep -o -P '(?<="url":").*(?=&pid=hp)')"
curl -o /tmp/wallpaper.jpg -L  $finalurl1$finalurl2
wait
gsettings reset org.cinnamon.desktop.background picture-uri
gsettings set org.cinnamon.desktop.background picture-uri  file:///tmp/wallpaper.jpg

echo $e$b >> /tmp/wallcomb
lines=$(wc -l < /tmp/wallcomb)
if [ $lines -ge 64 ]; then
> /tmp/wallcomb
fi

exit


you must edit the code below to tweak it for kde cause mine is made for cinnamon

gsettings reset org.cinnamon.desktop.background picture-uri
gsettings set org.cinnamon.desktop.background picture-uri  file:///tmp/wallpaper.jpg

And, don’t forget “Picture of the Day” the Get New Plugins which has dozens more. Personally I use Slideshow and change the image every 24hrs which I download and put in the folder /home/fredt/Pictures/Wallpaper/

Am i got you right? I can made something like this:

#!/bin/bash
feh --bg-fill [path/to/img/i/wanna/use/as/bg]

and it will work

Just simply

plasma-apply-wallpaperimage /path/to/image

thank you^^

I understand this is a bit not according to the rules of the forum, but is it possible to find out what bg picture is set now via the same command?

read conf file changed by this command :wink:

grep -A2 '\[org.kde.image\]' ~/.config/plasma-org.kde.plasma.desktop-appletsrc

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.