wallpaperslide.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. function make_js {
  3. js=$(mktemp)
  4. cat > $js <<_EOF
  5. var wallpaper = "$X";
  6. var activity = activities()[0];
  7. activity.currentConfigGroup = new Array("Wallpaper", "image");
  8. activity.writeConfig("wallpaper", wallpaper);
  9. activity.writeConfig("userswallpaper", wallpaper);
  10. activity.reloadConfig();
  11. _EOF
  12. }
  13. function kde_wallpaper {
  14. make_js
  15. qdbus org.kde.plasma-desktop /MainApplication loadScriptInInteractiveConsole $js > /dev/null
  16. # sleep 2
  17. xdotool search --name "Desktop Shell Scripting Console -- Plasma Desktop Shell" windowactivate key ctrl+e key ctrl+w
  18. rm -f "$js"
  19. dbus-send --dest=org.kde.plasma-desktop /MainApplication org.kde.plasma-desktop.reparseConfiguration
  20. dbus-send --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ReloadConfig
  21. dbus-send --dest=org.kde.kwin /KWin org.kde.KWin.reloadConfig
  22. # kbuildsycoca4 2>/dev/null && kquitapp plasma-desktop 2>/dev/null ; kstart plasma-desktop > /dev/null 2>&1
  23. }
  24. function xfce_wallpaper {
  25. xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s "$X"
  26. }
  27. function lxde_wallpaper {
  28. pcmanfm -w "$X"
  29. }
  30. function mate_wallpaper {
  31. gsettings set org.mate.background picture-filename "$X"
  32. }
  33. function e17_wallpaper {
  34. OUTPUT_DIR=~/.e/e/backgrounds
  35. FileName="$X"
  36. edcFile=~/tmp/SlideShow.edc
  37. echo 'images { image: "'$FileName'" LOSSY 90; }' > $edcFile
  38. echo 'collections {' >> $edcFile
  39. echo 'group { name: "e/desktop/background";' >> $edcFile
  40. echo 'data { item: "style" "4"; }' >> $edcFile
  41. echo 'data.item: "noanimation" "1";' >> $edcFile
  42. echo 'max: 990 742;' >> $edcFile
  43. echo 'parts {' >> $edcFile
  44. echo 'part { name: "bg"; mouse_events: 0;' >> $edcFile
  45. echo 'description { state: "default" 0.0;' >> $edcFile
  46. echo 'aspect: 1.334231806 1.334231806; aspect_preference: NONE;' >> $edcFile
  47. echo 'image { normal: "'$FileName'"; scale_hint: STATIC; }' >> $edcFile
  48. echo '} } } } }' >> $edcFile
  49. edje_cc -nothreads ~/tmp/SlideShow.edc -o $OUTPUT_DIR/SlideShow.edj
  50. sleep 2 && rm -f ~/tmp/SlideShow.edc
  51. echo 'Enlightenment e17 SlideShow.edj file created'
  52. enlightenment_remote -desktop-bg-del 0 0 -1 -1
  53. enlightenment_remote -desktop-bg-add 0 0 -1 -1 $OUTPUT_DIR/SlideShow.edj;
  54. }
  55. function usage {
  56. printf "%s\n%s\n\n%s\n%s\n\n%s\n\n%s" \
  57. "Automatically set a random image as the desktop wallpaper,"\
  58. "from the user's ~/Wallpaper directory."\
  59. "Idea from a script by Just17. Written by Paul Arnote for PCLinuxOS."\
  60. "Originally published in The PCLinuxOS Magazine (http://pclosmag.com), Jan. 2014 issue."\
  61. "Works for KDE4, Xfce, LXDE, Mate and e17 desktops."\
  62. "Usage: $0 [arguments]"\
  63. printf "\n %s\t%s" \
  64. "-h, --help" "This help text"
  65. printf "\n %s\t\tSetup for the %s" \
  66. "--xfce" "XFCE4 Desktop"\
  67. "--mate" "Mate Desktop"\
  68. "--lxde" "LXDE Desktop"\
  69. "--kde4" "KDE4 Desktop"\
  70. "--e17" "Enlightenment Desktop"
  71. printf "\n"
  72. }
  73. DIR=$HOME/Pictures/Wallpapers/
  74. #DIR=/usr/share/enlightenment/data/backgrounds/
  75. if [ "$1" == "--help" ] || [ "$1" == "-h" ] || [ "$1" == "" ]; then
  76. usage
  77. exit
  78. fi
  79. while true; do
  80. X=`find $DIR -type f \( -name '*.edj' -o -name '*.jpg' -o -name '*.png' \) -print0 | shuf -n1 -z`
  81. # For Xfce
  82. if [ "$1" == "--xfce" ]; then
  83. xfce_wallpaper
  84. fi
  85. # For LXDE
  86. if [ "$1" == "--lxde" ]; then
  87. lxde_wallpaper
  88. fi
  89. # For Mate
  90. if [ "$1" == "--mate" ]; then
  91. mate_wallpaper
  92. fi
  93. # For KDE4
  94. if [ "$1" == "--kde4" ]; then
  95. kde_wallpaper
  96. fi
  97. # For e17
  98. if [ "$1" == "--e17" ]; then
  99. e17_wallpaper
  100. fi
  101. #
  102. # If using Cairo-Dock add the following line
  103. # killall cairo-dock && sleep 0.3 && exec cairo-dock
  104. sleep 30m
  105. done
  106. exit 0