Advertisement
Rnery

KDE wallpaper changer..

Jun 25th, 2022 (edited)
1,329
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | Source Code | 1 0
  1. #!/usr/bin/env bash
  2.  
  3. full_image_path=$(realpath "$1")
  4. ext=$(file -b --mime-type "$full_image_path")
  5.  
  6. if [ -z "$2" ]; then
  7.     # Identify filetype and make changes
  8.     case $(echo $ext | cut -d'/' -f2) in
  9.         "mp4"|"webm") type='VideoWallpaper' ; write='VideoWallpaperBackgroundVideo';;
  10.         "png"|"jpeg") type='org.kde.image' ; write='Image' ;;
  11.         "gif")        type='GifWallpaper' ; write="GifWallpaperBackgroundGif" ;;
  12.     esac
  13. else
  14.     type="$2";
  15.     write="$3";
  16. fi
  17.  
  18. wallpaper_set_script="var allDesktops = desktops();
  19.    print (allDesktops);
  20.    for (i=0;i<allDesktops.length;i++) {
  21.        d = allDesktops[i];
  22.        d.wallpaperPlugin = '${type}';
  23.        d.currentConfigGroup = Array('Wallpaper', '${type}', 'General');
  24.        d.writeConfig('$write', 'file://${full_image_path}')
  25.    }"
  26.  
  27. qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "${wallpaper_set_script}"
  28.  
  29. # Optional, change lockscreen if you want
  30. kwriteconfig5 --file kscreenlockerrc --group Greeter --group Wallpaper --group org.kde.image --group General --key Image "file://$full_image_path"
Tags: Linux BASH kde
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement