chuggerguy

createBackgroundSlideshow

Nov 12th, 2026
29
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. SAVEIFS=$IFS
  4. IFS=$(echo -en "\n\b")
  5.  
  6. [[ -z $1 ]] && duration=3 || duration=$1
  7. [[ -z $2 ]] && transition=3 || transition=$2
  8. [[ -z $3 ]] && style=stretched || style=$3
  9.  
  10. slideshowname=slideshow.xml
  11. imagedirectory="$PWD"
  12.  
  13. images=($(find ~+ -maxdepth 1 -iregex ".*\(jpg\|jpeg\|png\|gif\|bmp\|webm\)$"))
  14. [[ -z $images ]] && echo "no images found" && exit
  15. numImages="${#images[@]}"
  16. echo "found $numImages images"
  17.  
  18. echo '<background>' > $slideshowname
  19.  
  20. for i in $(seq 0 $numImages); do
  21.     echo '  <static>' >> $slideshowname
  22.     echo "    <duration>$duration</duration>" >> $slideshowname
  23.     echo "    <file>"${images[$i]}"</file>" >> $slideshowname
  24.     echo "  </static>" >> $slideshowname
  25.     echo "  <transition>" >> $slideshowname
  26.     echo "    <duration>$transition</duration>" >> $slideshowname
  27.     echo "    <from>${images[$i]}</from>" >>$slideshowname
  28.     if [[ $i -lt $numImages-1 ]]; then
  29.         echo "    <to>${images[$i+1]}</to>" >>$slideshowname
  30.     else
  31.         echo "    <to>${images[0]}</to>" >>$slideshowname
  32.         echo "  </transition>" >> $slideshowname
  33.         break
  34.     fi
  35.     echo "  </transition>" >> $slideshowname
  36. done
  37.  
  38. echo '</background>' >> $slideshowname
  39.  
  40. gsettings set org.mate.background picture-filename "$imagedirectory/$slideshowname"
  41. gsettings set org.mate.background picture-options $style
  42.  
  43. IFS=$SAVEIFS
Advertisement
Comments
  • chuggerguy
    10 days
    # text 0.12 KB | 0 0
    1. gsetting lines written for MATE because that's what I use. Easy enough to Google the proper lines for other distros. :)
Add Comment
Please, Sign In to add comment