Dépôt initial
This commit is contained in:
49
bin/random_wallpaper
Executable file
49
bin/random_wallpaper
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# random_wallpaper
|
||||
#
|
||||
# Requirement: feh (apt install feh)
|
||||
|
||||
directory="$HOME/wallpapers"
|
||||
minutes=15
|
||||
|
||||
# Some tests
|
||||
if [ -z "`which feh`" ]; then
|
||||
echo "This script needs the feh program. Install it."
|
||||
i exit 1
|
||||
fi
|
||||
|
||||
if [ -d '$directory' ]; then
|
||||
echo "No $directory found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IFS="
|
||||
"
|
||||
|
||||
array_files=($(ls -1 $directory))
|
||||
|
||||
nb_files=`ls $directory|wc -l`
|
||||
|
||||
if [ $nb_files == 0 ]; then
|
||||
echo "$nb_files files in $directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# initialisation
|
||||
seconds=$[ $minutes * 60 ]
|
||||
|
||||
while true; do
|
||||
|
||||
# Random number generator (not more than files number)
|
||||
NUMBER=$[ ( $RANDOM % $nb_files ) ]
|
||||
|
||||
# Change background
|
||||
file="${array_files["$NUMBER"]}"
|
||||
feh --bg-fill "$directory/$file"
|
||||
|
||||
# Wait some times
|
||||
sleep $seconds
|
||||
done
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user