How to check gmail from the Xfce panel

Post Reply
User avatar
Salix Wizard
Posts: 5586
Joined: 6. Jun 2009, 17:40

How to check gmail from the Xfce panel

Post by gapan » 11. Dec 2012, 08:40

In Salix 14.0, the xfce mailwatch plugin is no more. It hasn't been updated for a while and it doesn't build against xfce 4.10.

A user in the greek subforum has asked for a way to check his gmail and I came up with this solution that involves the xfce4-genmon-plugin, that can display any kind of information in the panel. We only need to get that information from somewhere and it turns out that any gmail account has an RSS feed attached to it, so we can use feedparser to read that feed.

If you don't have them already, install the xfce4-mailwatch-plugin and feedparser packages.

Put the following code in a file, somewhere, anywhere you like, changing the account details at the top:

Code: Select all

#!/usr/bin/env python

USERNAME = "yourgmailusername"  # This is the part that is before
PASSWORD = "yourpassword"

# if you don't like the icons, change them to whichever you like
icon_unread = "/usr/share/icons/mate/16x16/status/mail-unread.png"
icon_read = "/usr/share/icons/mate/16x16/status/mail-read.png"

# you probably don't have to change anything below this part

import feedparser

unread = feedparser.parse("https://"+USERNAME+":"+PASSWORD+"")["feed"]["fullcount"]

if int(unread) > 0:
        icon = icon_unread
        text = "Unread emails: "+unread
        icon = icon_read
        text = "No unread emails."

print "<img>"+icon+"</img>"
print "<tool>"+text+"</tool>"
Now make that file executable:

Code: Select all

chmod +x /path/to/file
And add a Generic Monitor applet in your Xfce panel. Enter the full path to the file you just saved, untick the label as you probably don't need one and change the time interval to the one you want (like 60 seconds for 1-minute intervals between checks). This should display a different icon when you have any unread emails and also a tooltip with the number of unread emails.

If you want the icon to launch your browser with gmail when you click on it, you can add something like this at the end of the script:

Code: Select all

print "<click>midori</click>"

User avatar
Posts: 303
Joined: 13. Aug 2010, 04:53
Location: Ct. USA

Re: How to check gmail from the Xfce panel

Post by sqlpython » 10. Jan 2013, 19:32

Just got an opportunity to try the above python script.... Works well..
Although running Xfce4 13.1 I continue to have access to Mail-Watch.
Debian ( Stretch 9, Sid ) Salix OpenBox 14.1, Gentoo, Calculate

Post Reply