Skip to content

Instantly share code, notes, and snippets.

@scarolan
Last active December 20, 2015 02:49
Show Gist options
  • Save scarolan/6059066 to your computer and use it in GitHub Desktop.
Save scarolan/6059066 to your computer and use it in GitHub Desktop.
Same as console_screensaver.sh but with the width set to 150. Make sure to maximize your terminal window before running!
#!/bin/bash
# Set a higher ulimit so we don't segfault
ulimit -s 32768
search_string=$1
search_string=${search_string// /%20}
# Courtesy of heptal's Console Colors
# https://gist.github.com/heptal/6052573
function image() {
convert "$1" -resize "$2" txt:-|sed -E 's/://;s/\( ? ?//;s/, ? ?/,/g;s/\)//;s/(\w,\w,\w),\w/\1/g;/mage/d'|awk '{print $1,$2}'|python -c "import sys;f=sys.stdin.read().split('\n');f=filter(None,f);print 'tput rev;'+''.join([''.join(map(str,('echo;' if x.split(' ')[0].split(',')[0] is '0' else '','tput setaf '+str(sum(p*q for p,q in zip([36,6,1],[int(min(int(c),254)/42.5) for c in x.split(' ')[1].split(',')]))+16)+';echo -n \" \";'))) for x in f])+'echo;tput sgr0'"|bash
}
# Rotate through the current set of images, then try to grab some more!
while true; do
for url in $(curl -s http://api.flickr.com/services/feeds/photos_public.gne?tags=$search_string | grep -o 'href="http://farm[^"]*"' | sed 's/href="//' | sed 's/"//' | sed 's/b.jpg/m.jpg/'); do
image $url 150
sleep 30
clear
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment