You are not logged in.
Pages: 1
Hi guys, I made a script that changes the wallpaper randomly and never repeat it until all have been showed without compare them.
You can change the folder Changing Dir="$HOME/Pictures/.wallpaper", it must be a folder with only images or .hiden files.
Change feh --bg-fill "${Dir%/}/${Archivo}" if you don't use feh. and sleep for the transition time.
All tips are welcome.
#!/bin/bash
Dir="$HOME/Pictures/.wallpaper"
Totalfiles=$( find $Dir -type f \( -iname "*" ! -iname ".*" \) | wc - )
touch $Dir/.sorted.log
Tope="$( cat $Dir/.sorted.log | wc -l )"
if [ $Tope == 0 ]; then
Reseteador
fi
Aleatorio(){
rndn=$(( $RANDOM % $Tope ))
if [ $rndn == 0 ];then
rndn=$Tope
fi
RandomFile="$( cat $Dir/.sorted.log | head -n $rndn | tail -n 1)"
Archivo=$( ls -1 $Dir | head -n $RandomFile | tail -n 1 )
}
Imprimir(){
feh --bg-fill "${Dir%/}/${Archivo}"
sed -i "$rndn d" $Dir/.sorted.log
Tope="$( cat $Dir/.sorted.log | wc -l )"
sleep 5m
}
Reseteador(){
seq 1 $Totalfiles > $Dir/.sorted.log
Tope="$( cat $Dir/.sorted.log | wc -l )"
}
while true; do
if [ $Tope == 0 ]; then
Reseteador
fi
Aleatorio
Imprimir
done
Last edited by halcondx (2015-03-19 12:44:48)
Offline
Do not parse 'ls' http://mywiki.wooledge.org/ParsingLs
Last edited by karol (2015-03-19 12:14:47)
Offline
Fixed
$ ls -1 | wc -l
$ find $Dir -type f \( -iname "*" ! -iname ".*" \) | wc -l
Offline
Pages: 1