styli.sh
styli.sh copied to clipboard
Remove delay when switching wallpaper in KDE
I noticed that you have used a weird method to switch wallpaper in KDE. Which is kinda slow.
kde_cmd() {
cp ${wallpaper} "${cachedir}/tmp.jpg"
qdbus 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:${cachedir}/tmp.jpg\")}"
qdbus 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:${wallpaper}\")}"
sleep 5 && rm "${cachedir}/tmp.jpg"
}
I instead suggest you to use
wallpaper="${cachedir}/${RANDOM}.jpg"
and use this as the KDE function
kde_cmd() {
qdbus 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:${wallpaper}\")}"
}
Note that this method will pile up downloaded wallpapers inside cache directory.(which is not too bad) But theres a way to fix this issue : https://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/
The function is built that way because of multi-monitor support. KDE had a glitch where it sometimes wouldn't set the wallpaper for the second desktop. I assume this still works but I'm not familiar with KDE script, can you confirm it still works?
Sorry, I don't have multiple monitors right now. But there's an issue switching wallpaper. When I use the same command twice (for the same file path with the new wallpaper) the wallpaper doesn't change even with a single monitor. So that's why I thought to use random name for each wallpaper.