Mint Serena 64 bit using the Mate desktop environment. Most of the following scripts will run on this machine, although some have only been tested with the Gnome desktop. Extra software requirements can be met by the Ubuntu and safe PPA repositories. Scripts may be re-written or added to from time to time, the date serves as the version number. Syntax highlighting on these pages is provided by GVim's "Convert to HTML" option.

Gmail checker

#!/bin/bash
# Filename: gmail.sh
# Version: 020311
# Author: robz
# Checks on the half-hour if I have any new "Gmails".
# I don't know how to make this access the Gnome keyring so for now the script
# resides in an "ecryptfs" encrypted "Private" directory ie. username and pass
# in plain sight whilst logged in - good enough? - maybe not for the paranoid!
# You'll need to supply a bing bong sound and an icon.
# Add this to your user crontab - all on one line without the hash character.
# */30 * * * * export DISPLAY=:0 && /$HOME/Private/gmail.sh > /dev/null 2>&1

USER_NAME="<your_user_name>"
PASSWORD="<your_password>"
ICON="/usr/share/app-install/icons/kgmailnotifier.png"  # Gnomegmail now :)
HOUR=$(date $NOW +%H)

if [ "$HOUR" -lt "23" ]&&[ "$HOUR" -gt "7" ]; then      # Quiet 11pm to 7am.
    FROM=$(wget -T 3 -t 1 -q --secure-protocol=SSLv3 --no-check-certificate\
        --user=$USER_NAME --password=$PASSWORD\
        https://mail.google.com/mail/feed/atom -O - |\
        grep "</name>" | sed "s/[</>]//g; s/name//g")   # Who from.
        HM=$(echo "$FROM" | wc -l)                      # How many.
    if [ -n "$FROM" ]; then                             # Any senders.
        if [ "$HM" -gt "1" ]; then s="s"; fi            # Plural or singular.
        notify-send -i $ICON ">> NEW MAIL@gmail.com <<"\
        "$(echo -e Your inbox contains $HM new message$s\\n"$FROM")"
        /usr/bin/canberra-gtk-play --volume 6 -f $SOUND &
    fi
fi


No comments: