diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-08-03 16:16:50 +0200 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-08-03 16:16:50 +0200 |
commit | ee8c2306989f1d9d6d535840751580daebf11e5c (patch) | |
tree | e4cfbb53d1c0a8112ea11528b6b59de27b24bb84 | |
parent | Fixed gif resolution (diff) | |
download | smart-wallpaper-ee8c2306989f1d9d6d535840751580daebf11e5c.tar.gz smart-wallpaper-ee8c2306989f1d9d6d535840751580daebf11e5c.tar.bz2 smart-wallpaper-ee8c2306989f1d9d6d535840751580daebf11e5c.zip |
Added randomize option
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | smart-wallpaper | 19 |
2 files changed, 17 insertions, 3 deletions
diff --git a/README.md b/README.md index 96bd096..6bebc13 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Usage: smart-wallpaper [FLAG]<br /> [-n]: NEEDED : nighttime wallpaper file/folder<br /> [-l]: OPTIONAL : manual location (lat:long), if not added geoclue gets the location (requires internet)<br /> [-t]: OPTIONAL : set the time period (seconds) for the script to check if it is day or night<br /> + [-r]: OPTIONAL : changes the wallpaper every day/night iteration<br /> [-h]: OPTIONAL : print help message Example: diff --git a/smart-wallpaper b/smart-wallpaper index 9ec7aae..7c9c7a8 100755 --- a/smart-wallpaper +++ b/smart-wallpaper @@ -5,6 +5,7 @@ trap cleanup EXIT period=500 resolution=$(xdpyinfo | awk '/dimensions/{print $2}') +randomize=false input_daytimewallpaper='' input_nighttimewallpaper='' daytimewallpaper='' @@ -28,6 +29,7 @@ print_usage() { echo " [-n]: NEEDED : nighttime wallpaper file/folder" echo " [-l]: OPTIONAL : manual location (lat:long), if not added geoclue gets the location (requires internet)" echo " [-t]: OPTIONAL : set the time period (seconds) for the script to check if it is day or night " + echo " [-r]: OPTIONAL : changes the wallpaper every day/night iteration" echo " [-h]: OPTIONAL : print help message" } @@ -52,12 +54,20 @@ checktime() { if redshift -l $location -p | grep -i -q "$currenttime"; then timebool=true else + if [ "$randomize" == true ]; then + daytimewallpaper=$(find $input_daytimewallpaper -type f | shuf -n 1) + nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) + fi timebool=false fi else if redshift -p | grep -i -q "$currenttime"; then timebool=true else + if [ "$randomize" == true ]; then + daytimewallpaper=$(find $input_daytimewallpaper -type f | shuf -n 1) + nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) + fi timebool=false fi fi @@ -68,12 +78,13 @@ if (( $# == 0 )); then exit 1 fi -while getopts 'd:n:l:t:h' flag; do +while getopts 'd:n:l:t:rh' flag; do case "${flag}" in d) input_daytimewallpaper="${OPTARG}" ;; n) input_nighttimewallpaper="${OPTARG}" ;; t) period="${OPTARG}" ;; l) location="${OPTARG}" ;; + r) randomize=true ;; h) print_usage exit 0 ;; *) print_usage @@ -91,8 +102,10 @@ if [ "$input_nighttimewallpaper" == "" ]; then exit 1 fi -daytimewallpaper=$(find $input_daytimewallpaper -type f | shuf -n 1) -nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) +if [ "$randomize" == false ]; then + daytimewallpaper=$(find $input_daytimewallpaper -type f | shuf -n 1) + nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) +fi while true do |