scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 4272dad5c2d896befc743e63044b71c1fc59bec3
parent 60712b67b59d0cbd29a8962b49dd56e8a32e0783
Author: clamiax <smoppy@gmail.com>
Date:   Sun, 25 Oct 2015 20:11:33 +0100

[scrapthumb] Support GIFs.

Diffstat:
MREADME.md | 40++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md @@ -36,8 +36,8 @@ Some sample usages in ~/.xinitrc: sleep 5m done & - # Change wallpaper each 5 minutes by storing the source - # into /tmp/.scrapthumb (new with the -u flag) + # Change wallpaper each 5 minutes by storing the source into + # /tmp/.scrapthumb (new with the -u flag) while true; do t="$(~/sources/scripts/scrapthumb -urn1)" src=$(echo $t |cut -d'|' -f1) @@ -48,6 +48,42 @@ Some sample usages in ~/.xinitrc: sleep 5m done & +A more complex example with GIFs support (CPU intensive): + + # Change wallpaper each 5 minutes by storing the source into + # /tmp/.scrapthumb (new with the -u flag). If the image is a GIF, then + # it's split into frames which are then progressively set as + # background, with 1ms of delay. + while : ; do + intval=300 + scrap="$(scrapthumb -urn1)" + uri="$(echo "$scrap" |cut -d'|' -f2)" + ext="$(echo "$uri" |rev |cut -d. -f1 |rev)" + if [ "$ext" = "gif" ]; then + d="$(mktemp -u /tmp/xinitrc.XXXXX)" + mkdir -p "$d" + convert "$uri" "$d/t.jpg" + ts="$(date +'%s')" + t=0 + while [ "$t" -lt "$intval" ]; do + for jpg in "$d/"*.jpg; do + feh --bg-fill --no-fehbg "$jpg" + sleep 0.01 + t="$(echo "$ts - $(date +'%s')" |bc)" + # never exceed $intval + [ "$t" -ge "$intval" ] && break + done + done + rm -rf "$d" + else + feh --bg-fill --no-fehbg "$uri" + fi + echo "$scrap" > /tmp/scrapthumb + sleep "$intval" + done & + +This approach requires convert(1) from the ImageMagick suite. + You can achieve more extreme results by using scrapthumb in conjunction with semi-automatic customization tool. Have a look at [autotheme.sh](https://github.com/neeasade/autotheme.sh).