Skip to content

Instantly share code, notes, and snippets.

@omerk
Created May 22, 2016 20:54
Show Gist options
  • Save omerk/518bdc99a73568ceb3201fa4990d594e to your computer and use it in GitHub Desktop.
Save omerk/518bdc99a73568ceb3201fa4990d594e to your computer and use it in GitHub Desktop.
#!/bin/bash
TWFR_SCREEN=/dev/fb0
TWFR_USER=shibesbot
TWFR_ROTATE=180 # Comment this out if rotation is not necessary
# Grab the latest photo from timeline
twphotos -u $TWFR_USER -i -n 1 | grep "No new"
if [ $? == 0 ]; then
echo "no new photo"
exit 1
else
echo "new photo!"
# Switch over to the cache directory
cd $TWFR_USER
# Pick the latest photo from the cache
TWFR_PHOTO=`find * -printf '%T+ %p\n' | sort -r | head -n 1 | awk '{print $2}'`
# OPTIONAL: Rotate photo, if variable ROTATE is set
if [ -v TWFR_ROTATE ]; then
convert -rotate $TWFR_ROTATE $TWFR_PHOTO $TWFR_PHOTO
fi
# Display photo
sudo fbi -T 2 -d $TWFR_SCREEN -noverbose -a $TWFR_PHOTO
# Get rid of stale photos
find * -type f -not -name $TWFR_PHOTO | xargs rm
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment