Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rtd_oem_kde_set_wallpaper ()
- {
- # Description:
- # Function to set KDE Plasma wallpaper from a script. this function expects one variable
- # indication what file to set as background. You must provide the full path to the file.
- # rtd_oem_kde_set_wallpaper /opt/oem/wallpaper.png Supported fule types are:
- # webm, mp4, png, jpeg, gif, webp.
- # Globals:
- # Arguments: None
- # Outputs:
- # Returns:
- # Usage:
- # End of documentation
- echo "Setting wallpaper $1"
- full_image_path=$(realpath "$1")
- ext=$(file -b --mime-type "$full_image_path")
- if [ -z "$2" ]; then
- # Identify filetype and make changes
- case $(echo $ext | cut -d'/' -f2) in
- "mp4"|"webm") type='VideoWallpaper' ; write='VideoWallpaperBackgroundVideo';;
- "png"|"jpeg"|"jpg") type='org.kde.image' ; write='Image' ;;
- "gif"|"webp") type='GifWallpaper' ; write="GifWallpaperBackgroundGif" ;;
- esac
- else
- type="$2";
- write="$3";
- fi
- wallpaper_set_script="var allDesktops = desktops();
- print (allDesktops);
- for (i=0;i<allDesktops.length;i++)
- {
- d = allDesktops[i];
- d.wallpaperPlugin = '${type}';
- d.currentConfigGroup = Array('Wallpaper', '${type}', 'General');
- d.writeConfig('Image', 'file:///dev/null')
- d.writeConfig('$write', 'file://${full_image_path}')
- }"
- # have to put in these stupid fixes because distros can't agree where to but stuff!
- hash qdbus || ${_qdbus="$(/usr/bin/qdbus-qt5)"} && ${_qdbus="qdbus"}
- ${_qdbus} org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript "${wallpaper_set_script}"
- kwriteconfig5 --file kscreenlockerrc --group Greeter --group Wallpaper --group org.kde.image --group General --key Image "file://$full_image_path"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement