-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathback4.sh
executable file
·34 lines (26 loc) · 1.26 KB
/
back4.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/env bash
select1='feh --bg-fill --no-fehbg '
select2='xwallpaper --zoom '
select3='xloadimage -onroot -fullscreen '
select4='xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s '
select5='hsetroot -full '
select6='gsettings set org.gnome.desktop.background picture-uri file:///'
prog=$select1
[ "$#" -lt "1" ] || [ "$#" -gt "2" ] && { echo -e "ERROR : args number invalid \n $0 speed /path/name.gif" ; echo "try 0.010 as speed" ; exit 1 ; }
dir=/tmp/back4
#example of speed : 0.010
speed=$1
name=$2
[[ "$name" == "" ]] && { name=$speed ; speed=${name##*-} ; }
[ ! -f "$name" ] && { echo "file not found" ; exit 1 ; }
[ -f "/usr/local/share/gif-wallpaper/loading.png" ] && ${select1}/usr/local/share/gif-wallpaper/loading.png
hash=`md5sum $name | cut -f1 -d" "`
[[ ! -d $dir ]] && mkdir $dir
[[ ! -d $dir/$hash ]] && { mkdir $dir/$hash ; echo "spliting .." ; convert -coalesce $name $dir/$hash/$hash.png ; echo ok ; }
if [ "$1" == "auto" ]; then
frames=($(ls -v "$dir/$hash"))
amount_of_frames=${#frames[@]}
frames_per_second=30
speed=$(bc <<< "scale=3; ($amount_of_frames/$frames_per_second) * (1/$frames_per_second)")
fi
while : ; do for i in ` ls $dir/$hash -v ` ; do $prog$dir/$hash/$i ; sleep $speed ; done ; done