gnome-background (1481B)
1 #!/usr/bin/env bash 2 die() { 3 echo "$1" >&2 4 exit 1 5 } 6 loop_backgrounds() { 7 for i in /home/zeroalpha/Pictures/Backgrounds/"$1"/*; do 8 gsettings set org.gnome.desktop.background picture-uri "$i"; 9 echo -n "$i: "; 10 echo "press enter to continue, c to copy"; 11 read -rsn 1 key; 12 if [ "$key" = "c" ]; then 13 if ! command -v xclip &>/dev/null; then 14 echo "xclip not installed." >&2 15 else 16 xclip -sel clip <<< "$i" 17 echo "copied" 18 fi 19 fi 20 done 21 } 22 temp_set_background() { 23 echo "Setting to $1" 24 gsettings set org.gnome.desktop.background picture-uri "file://$1"; 25 echo "Press enter to continue." 26 read -rsn 1 c; 27 reset_background 28 } 29 [ -d /home/zeroalpha/Pictures/Backgrounds ] || die "No backgrounds folder." 30 31 save_current() { 32 current=$(gsettings get org.gnome.desktop.background picture-uri) 33 trap reset_background INT TERM KILL EXIT 34 } 35 reset_background() { 36 gsettings set org.gnome.desktop.background picture-uri "$current"; 37 trap - INT TERM KILL EXIT 38 exit 0 39 } 40 if [ "$1" = "audition" ]; then 41 [ $# -eq 2 ] || die "Light or dark?" 42 save_current 43 loop_backgrounds "$2" 44 elif [ "$1" = "test" ]; then 45 [ $# -eq 2 ] || die "No background provided." 46 save_current 47 temp_set_background "$2" 48 elif [ "$1" = "print" ]; then 49 gsettings get org.gnome.desktop.background picture-uri; 50 else 51 if [ $# -eq 1 ]; then 52 echo "Setting background to $1" 53 gsettings set org.gnome.desktop.background picture-uri "file://$1"; 54 fi 55 fi