diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-29 02:05:35 +0200 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-29 02:05:35 +0200 |
commit | 013e52ffd4ec16e5a8f775030fcb11dbcacbd0f4 (patch) | |
tree | cc44b71af154cc51b61f96a526700eb027529e80 | |
parent | Removed config file (diff) | |
download | smart-wallpaper-013e52ffd4ec16e5a8f775030fcb11dbcacbd0f4.tar.gz smart-wallpaper-013e52ffd4ec16e5a8f775030fcb11dbcacbd0f4.tar.bz2 smart-wallpaper-013e52ffd4ec16e5a8f775030fcb11dbcacbd0f4.zip |
Complete rewrite, many improvements
-rwxr-xr-x | smart-wallpaper | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/smart-wallpaper b/smart-wallpaper index 3d300ec..576d76a 100755 --- a/smart-wallpaper +++ b/smart-wallpaper @@ -1,23 +1,64 @@ #!/bin/bash -source ~/.config/smart-wallpaper/config +input_daytimewallpaper='' +input_nighttimewallpaper='' +daytimewallpaper='' +nighttimewallpaper='' +location='' + +print_usage() { + echo "Usage: smart-wallpaper [FLAG]" + echo " Flags:" + echo " [-d]: NEEDED : daytime wallpaper file/folder" + echo " [-n]: NEEDED : nighttime wallpaper file/folder" + echo " [-l]: OPTIONAL : manual location, if not added geoclue gets the location (requires internet)" + echo " [-h]: OPTIONAL : print help message" +} + +if (( $# == 0 )); then + print_usage +fi + +while getopts 'd:n:l:h' flag; do + case "${flag}" in + d) input_daytimewallpaper="${OPTARG}";; + n) input_nighttimewallpaper="${OPTARG}";; + l) location="${OPTARG}";; + h) print_usage ;; + *) print_usage + exit 1 ;; + esac +done + +if [ "$input_daytimewallpaper" == "" ]; then + print_usage + exit 1 +fi + +if [ "$input_nighttimewallpaper" == "" ]; then + print_usage + exit 1 +fi + +daytimewallpaper=$(find $input_daytimewallpaper -type f | shuf -n 1) +nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) while true do - if [ -f /usr/share/geolocate/.location ]; then - string=$(redshift -l $(cat /usr/share/geolocate/.location) -p) + if [ "$location" != "" ]; then + string=$(redshift -l $location -p) if [[ $string == *"Daytime"* ]]; then - feh --randomize --bg-fill $daytimewallpaper + feh --bg-fill $daytimewallpaper else - feh --randomize --bg-fill $nightimewallpaper + feh --bg-fill $nighttimewallpaper fi else string=$(redshift -p) if [[ $string == *"Daytime"* ]]; then - feh --randomize --bg-fill $daytimewallpaper + feh --bg-fill $daytimewallpaper else - feh --randomize --bg-fill $nightimewallpaper + feh --bg-fill $nighttimewallpaper fi fi |