#!/bin/sh
# Blog post: http://platechnotes.patrickarchibald.com/2011/08/watch-folder-and-send-images-to-your.html
# 1. Watch ~/PicasaWeb folder.
# 2. Upload new file to Picasa using Google CLI.
# 3. Launch the browser to Google Plus photos URL.
#
WATCHED_DIR=~/PicasaWeb
googleVersion=$(google --version)
echo $googleVersion
while [ 1 ]
do
echo 'Watching directory: '$WATCHED_DIR 'for new files'
while file=$(inotifywait -q -e create "$WATCHED_DIR" --format "%f")
do
echo 'New file to upload to PicasaWeb:' $file
notify-send -i "gtk-go-up" "Picasa Web Monitor" "Uploading image $file"
mythtvosd --template=alert --alert_text="Uploading image $file"
google picasa post --title "Instant Upload" "$WATCHED_DIR/$file"
if [ "$googleVersion" = "google 0.9.5" ]; then
url=$(google picasa list url-direct --title "Instant Upload" | grep "$file" | sed -e "s/$file\,//g")
else
url=$(google picasa list --fields url-direct --title "Instant Upload" | grep "$file" | sed -e "s/$file\,//g")
fi
echo 'Picasa url: ' $url
notify-send -i "gtk-home" "Picasa Web Monitor" "Image uploaded. Starting Gwibber and going to G+"
xdg-open https://plus.google.com/photos/fromphone
python ~/Ubuntu\ One/scripts/gwibber-widget.py $url
done
done
Prerequisites and Instructions
- You should be running Linux. I am using Ubuntu
- You need the command
inotifywait
. On Ubuntu I installed it viasudo apt-get install inotify-tools
- You must have a Picasa account
- Install libnotify-bin for the
notify-send
command - Install Google CLI
- Create "PicasaWeb" folder in your home directory
mkdir ~/PicasaWeb
- Copy and paste my bash script above into a file. I named mine PicasaWebMonitor.sh.
- Make PicasaWebMonitor.sh executable
chmod +x PicasaWebMonitor.sh
- Start the bash script
./PicasaWebMonitor.sh
. - Create some images and save them to the ~/PicasaWeb folder
- Avoid using spaces and special characters in your picture file names. The Picasa Web direct URL will be encoded and won't match your file name. The grep statement will fail to show you the direct URL.
Let me know if you find any bugs in this script or if there is a better way to do it.
No comments:
Post a Comment