Skip to content

Instantly share code, notes, and snippets.

@sampowers
Created February 22, 2013 21:57
Show Gist options
  • Save sampowers/5016863 to your computer and use it in GitHub Desktop.
Save sampowers/5016863 to your computer and use it in GitHub Desktop.
plonk
#!/bin/sh
. ~/.plonkrc # defines TWUSER and TWPASS. chmod 600 it... also define SMTPHOST there.
plonkmail() {
sendEmail \
-f `whoami`@`hostname -f` -t $MAILTO -u "$1" -m `basename $1` \
-s $SMTPHOST \
-a "$1"
}
FILE=`mktemp /tmp/plonk.XXXXXX`
mv "$FILE" "${FILE}.png"
scrot -s ${FILE}.png
case "$1" in
twitpic)
eog $FILE.png &
MESSAGE=`zenity --entry --text="Tweet away, or cancel to bail."`
if [ -z $MESSAGE ]; then
rm $FILE.png
exit 1
fi
curl \
-F media=@${FILE}.png \
-F username=${TWUSER} \
-F password=${TWPASS} \
-F message="${MESSAGE}" \
http://twitpic.com/api/uploadAndPost
rm ${FILE}.png
;;
grab)
plonkmail ${FILE}.png
mv ${FILE}.png $GRABDIR
gnome-open $GRABDIR
;;
*)
echo "Usage: $0 {twitpic|grab}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment