,wallpaper_changer.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # Coding: utf-8
  3. # Editor: www.geany.org
  4. # Created 2016-12-18
  5. # for xfce4 desktop enviroment
  6. # xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitorVGA-1/workspace0/last-image --set "$(cat ~/LOG/,wallpaper_changer.sh/last_wallpaper)" for setup current wallpaper
  7. export DISPLAY=:0
  8. export XAUTHORITY=/home/a/.Xauthority
  9. export XDG_RUNTIME_DIR=/run/user/$(id -u)
  10. source $HOME/.SCR/lib.sh
  11. fun_log_dir_create $0 365
  12. con_test_not_exist_process
  13. dir_new="$HOME/DATA2/Wallpapers/new"
  14. dir_used="$HOME/DATA2/Wallpapers/used"
  15. last_wall_logfile="$dir_script/last_wallpaper"
  16. read last_wall_path < $last_wall_logfile
  17. fun_analize_command "Read wallpaper path from file"
  18. fun_create_directory "$dir_new" "$dir_used"
  19. if [ -d "$dir_new" ] # if folder with wallpaper exist
  20. then
  21. wall_name=`ls $dir_new | shuf -n 1`
  22. fun_analize_command "Get random wallpaper file path"
  23. new_wall_path="$dir_new/$wall_name"
  24. fun_echo_variable last_wall_path new_wall_path
  25. if [ -n "$new_wall_path" ] # if file exist
  26. then
  27. xfconf-query --channel xfce4-desktop --property /backdrop/screen0/monitorVGA-1/workspace0/last-image --set "$new_wall_path"
  28. fun_analize_command "Setup wallpaper $new_wall_path"
  29. if [ -s "$last_wall_path" ] # if last wallpaper path exist
  30. then
  31. if [ "$1" == "del" ] # if first argument is "del"
  32. then
  33. rm -rf "$last_wall_path"
  34. fun_analize_command "Delete file $last_wall_path"
  35. else
  36. touch "$last_wall_path"
  37. fun_analize_command "Set new time date to wallpaper file"
  38. mv "$last_wall_path" "$dir_used"
  39. fun_analize_command "Move file to folder $dir_used"
  40. fi
  41. fi
  42. echo "$new_wall_path" > $last_wall_logfile
  43. fun_analize_command "Write new wallpaper path to file"
  44. echo "$date_utc" > "${dir_general}/lockfile_wallpaper_changer"
  45. ,speech_en.sh "New wallpaper installed"
  46. else
  47. fun_echo_stadia 11 0 "Files to wallpaper not exist"
  48. fi
  49. else
  50. fun_echo_stadia 11 0 "Folder to wallpaper not exist"
  51. fi