Package: gmailcount
gmailcount==========gmailcount is a simple script to count the number of emails in your gmailinbox. It's primary purpose is to allow status-bar programs like xmobar ori3bar to poll your inbox without the need to store your password in plaintext.Installation------------gmailcount is tested on python 3.5. It may work on older versions of python 3.Installation is simple:pip3 install gmailcountwith Secret Service support (gnome-keyring):pip3 install gmailcount[secretservice]gnome-keyring support also requires the `dbus-python` package which can't beinstalled via pip. It can be installed via system package manager (python3-dbuson Debian) or from source.If your system keyring isn't working you can install alternative keyring support:pip3 install gmailcount[altkeyrings]Alternative keyring support includes keyring backends that should work onalmost any system, but may not be as secure. For more information on keyringconfiguration check out the python keyring[documentation](https://pypi.python.org/pypi/keyring#configure-your-keyring-lib).Usage-----usage: gmailcount [-h] [-s | -d | -p] [-t TIMEOUT] [--debug] email_addressCheck gmail message count.positional arguments:email_address         email address to useoptional arguments:-h, --help            show this help message and exit-s, --set-password    set the password for email_address-d, --delete-passworddelete the password for email_address-p, --prompt          have gmail-count prompt you for your password-t TIMEOUT, --timeout TIMEOUTrequest timeout--debug               print any exception tracebackBefore you can use gmailcount in your status bar, you'll need to run it withthe `-s` flag to set the password for your email address. Once you've set yourpassword it will be stored in your system keyring. Any program using yourgmailcount will need to have access to your keyring.When used with no flags, gmailcount will print the number of emails in yourinbox to stdout or nothing in case of failure.Security concerns-----------------One of the main goals of gmailcount is to provide a minimum level ofsecurity. To that end, all requests are sent via SSL, passwords are stored inyour system keyring (and are presumably encrypted if your system keyring isworth anything), and the recommended use pattern is with app passwords onaccounts with two-factor authentication enabled. This allows you to keep yourpassword out of your dotfiles and encrypted, and to revoke your password incase your system is compromised.Obviously though any system that allows your computer to poll your emailwithout any human interaction isn't going to be ideal from a securitystandpoint. gmailcount is only as secure as your system keyring, whichdepending on how you use it and your configuration may not be very secure atall. Certainly if you're using gmailcount in a status bar, any one whomanages to get access to your logged in user account will have access to youremail, and if your keyring is secured by an insufficently strong password,someone with access to your harddrive may be able to crack your keyringpassword and access your gmail password.Use gmailcount at your own risk! Still, it should be a lot more secure than asystem that just stores your password as plain text at least.Sample xmobar script--------------------Here's an example of a script suitable for use with xmobar:#!/usr/bin/env shurl='https://mail.google.com'email='example@gmail.com'full_text=$(/path/to/gmailcount -t 0.3 "$email")full_text=${full_text:-?}case $full_text in''|*[!0-9]*) color=\#FF0000 ;;0)           color=\#888888 ;;*)           color=\#00FF00 ;;esacecho "<action=\`xdg-open $url\`><fc=$color>✉ $full_text</fc></action>"Sample i3blocks script----------------------Here's one suitable for use with i3blocks:#!/usr/bin/env shurl='https://mail.google.com'email='example@gmail.com'[ "$BLOCK_BUTTON" = 1 ] && xdg-open "$url"full_text=$(/path/to/gmailcount -t 0.3 "$email")full_text=${full_text:-?}case $full_text in''|*[!0-9]*) color=\#FF0000 ;;0)           color=\#888888 ;;*)           color=\#00FF00 ;;esacecho "$full_text"echo "$short_text"echo "$color"Sample Asynchrnous xmobar script--------------------------------Here's a somewhat more sophisticated script for xmobar which never blockswaiting for the google servers. It works by writing the data asynchronously toa temp file. The first argument to the script will set a timeout for writingthe data so that you can check gmail just before your status bar updates.Something similar should work for i3blocks.#!/usr/bin/env shSTATUSFILE=/tmp/.gmail-statusGMAILCOUNT=/path/to/gmailcountSLEEPTIME=${1:-0}EMAIL='example@gmail.com'URL='https://mail.google.com'echo_status() {echo "<action=\`xdg-open $URL\`><fc=$2><fn=1></fn> $1</fc></action>"}write_data() {sleep "$SLEEPTIME"full_text=$("$GMAILCOUNT" "$EMAIL")full_text=${full_text:-?}case $full_text in''|*[!0-9]*) color=\#FF0000 ;;0)           color=\#888888 ;;*)           color=\#00FF00 ;;esacecho_status "$full_text" "$color" > "$STATUSFILE"}touch "$STATUSFILE"output=$(cat "$STATUSFILE")[ ! -z "$output" ] && echo "$output" || echo_status "?" \#880088> "$STATUSFILE"write_data &