diff options
author | Archie Hilton (thytom) <archie.hilton1@gmail.com> | 2019-10-14 14:26:32 +0100 |
---|---|---|
committer | Archie Hilton (thytom) <archie.hilton1@gmail.com> | 2019-10-14 14:26:32 +0100 |
commit | 0f8f3dd424e20af2e8c26582250155e6fdae7aa6 (patch) | |
tree | 65a7807f2248aedb07f3f7f3e9dd514154cf8dc6 | |
parent | Added mkv support (diff) | |
download | smart-wallpaper-0f8f3dd424e20af2e8c26582250155e6fdae7aa6.tar.gz smart-wallpaper-0f8f3dd424e20af2e8c26582250155e6fdae7aa6.tar.bz2 smart-wallpaper-0f8f3dd424e20af2e8c26582250155e6fdae7aa6.zip |
Added framerate option. Usage: -f [FRAMERATE]
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | smart-wallpaper | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/README.md b/README.md index f61de10..213211b 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 /> + [-f]: OPTIONAL : set the framerate for the gif. Lower framerates = lower CPU usage.<br \> [-r]: OPTIONAL : changes the wallpaper every day/night iteration<br /> [-o]: OPTIONAL : [BETA] checks weather you are in fullscreen to stop the wallpaper (less cpu power)<br /> [-h]: OPTIONAL : print help message diff --git a/smart-wallpaper b/smart-wallpaper index 4076668..8260650 100755 --- a/smart-wallpaper +++ b/smart-wallpaper @@ -5,6 +5,8 @@ trap cleanup EXIT period=500 resolution=$(xdpyinfo | awk '/dimensions/{print $2}') +framerate='' +delay_flag='' randomize=false optimize=false input_daytimewallpaper='' @@ -35,6 +37,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 " [-f]: OPTIONAL : set the framerate for the gif. Lower framerates = lower CPU usage." echo " [-r]: OPTIONAL : changes the wallpaper every day/night iteration" echo " [-h]: OPTIONAL : print help message" } @@ -49,7 +52,7 @@ set_wallpaper() { if [ -f /usr/bin/xwinwrap ]; then if [ -f /usr/bin/gifview ] && [[ $1 == *".gif" ]]; then - echo "gifsicle --resize $resolution \$1 | gifview --animate -w \$2" > /tmp/smart-wallpaper-gifcmd + echo "gifsicle --resize $resolution $delay_flag \$1 | gifview --animate -w \$2" > /tmp/smart-wallpaper-gifcmd xwinwrap -ov -ni -s -nf -un -argb -g $resolution -- sh /tmp/smart-wallpaper-gifcmd $1 WID & procid=$! elif [ -f /usr/bin/mpv ] && [[ $1 == *".mp4" ]] || [[ $1 == *".mov" ]] || [[ $1 == *".avi" ]] || [[ $1 == *".mkv" ]]; then @@ -61,7 +64,7 @@ set_wallpaper() { fi else if [ -f /usr/bin/gifview ] && [[ $1 == *".gif" ]]; then - gifsicle --resize $resolution $1 | gifview --animate -w root & + gifsicle --resize $resolution $1 $delay_flag | gifview --animate -w root & procid=$! elif [ -f /usr/bin/mpv ] && [[ $1 == *".mp4" ]] || [[ $1 == *".mov" ]] || [[ $1 == *".avi" ]] || [[ $1 == *".mkv" ]]; then mpv --fullscreen --on-all-workspaces --no-config --no-input-default-bindings --no-stop-screensaver --loop-file --no-audio --no-osc --no-osd-bar -wid 0 --quiet $1 & @@ -129,11 +132,12 @@ if (( $# == 0 )); then exit 1 fi -while getopts 'd:n:l:t:roh' flag; do +while getopts 'd:n:l:t:f:roh' flag; do case "${flag}" in d) input_daytimewallpaper="${OPTARG}" ;; n) input_nighttimewallpaper="${OPTARG}" ;; t) period="${OPTARG}" ;; + f) framerate="${OPTARG}" ;; l) location="${OPTARG}" ;; r) randomize=true ;; o) optimize=true ;; @@ -159,6 +163,7 @@ if [ "$randomize" == false ]; then nighttimewallpaper=$(find $input_nighttimewallpaper -type f | shuf -n 1) fi +delay_flag="--delay $(expr 100 / $framerate)" while true do |