人気ブログランキング | 話題のタグを見る

GeektoolでGmailを表示してみる

Check your unread Gmail from the command line(コマンドラインから未読Gmailを表示する)

curl -u username:password –silent “https://mail.google.com/mail/feed/atom” | tr -d ‘\n’ | awk -F ” ‘{for (i=2; i<=NF; i++) {print $i}}’ | sed -n “s/\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 – \1/p”

Checks the Gmail ATOM feed for your account, parses it and outputs a list of unread messages.(GmailのATOMフィードをチェックして未読メッセージをリストにするよ.)

For some reason sed gets stuck on OS X, so here’s a Perl version for the Mac:(でもOS Xだと動かないから,MacのためにPerl版も書いておくね. )

curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/'If you want to see the name of the last person, who added a message to the conversation, change the greediness of the operators like this:(もし最終行の送信者名を表示させたかったら,以下のようにしてね.)
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/'
ということだ.なので,
echo "Gmail"
curl -u username:password --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | perl -pe 's/^<title>(.*)<\/title>.*?<name>(.*?)<\/name>.*$/$2 - $1/'
と,頭にechoしてガジェットタイトルとして"Gmail"を表示している. username,passwordはそれぞれgmailにログインするときに入力するusernameとpasswordを入れる.例えばユーザ名nemo(@gmail),パスワードhogehogeであれば,nemo:hogehogeとなる.
by n9ne2 | 2012-04-08 19:03 | 日記