Xfce Forum

Sub domains
 

You are not logged in.

#1 2016-02-29 16:28:44

ac220
Member
Registered: 2016-02-29
Posts: 4

[SOLVED] need a mail checker with a very specific feature...

Hi everyone, could someone help me?
Basically, there's that one Gmail inbox I have for not-exactly-spam, with lots of messages I never actually read and don't want marked read (because I didn't read them, and want to keep track of that.)

Mail Watcher that comes with Xubuntu and is recommended in most places I could find is almost exactly what I want, but with this kind of inbox it seems to simply permanently display that I've got a million new mails, without any obvious way to tell it to disregard any "new" mail that had been there for years... Thunderbird could do that but feels a bit like swatting gnats with a sledgehammer. Is there anything else? the more lightweight and unobtrusive the better.

Last edited by ac220 (2016-03-02 01:32:51)

Offline

#2 2016-03-01 05:02:17

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,006

Re: [SOLVED] need a mail checker with a very specific feature...

Hello and welcome.

Not a mailwatch solution (which can't be changed or configured like you're asking), but how about using a Google script to archive your older emails? This will move them out of the Inbox (which is checked by the mailwatch plugin) and into the All Mail folder (which is not checked).

Here is a script that deletes emails after 2 days. You can change the line:

threads[i].moveToTrash();

...to:

threads[i].moveToArchive();

...so that it archives instead.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2016-03-01 18:51:40

ac220
Member
Registered: 2016-02-29
Posts: 4

Re: [SOLVED] need a mail checker with a very specific feature...

Thanks, but that's still alteration of my inbox, which I do not want...
So, I guess Thunderbird is the only other relatively bloat-free option?

Last edited by ac220 (2016-03-01 18:52:23)

Offline

#4 2016-03-02 00:55:26

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,006

Re: [SOLVED] need a mail checker with a very specific feature...

How about this as an option?

Here is a script that I've thrown together that works with the xfce4-genmon-plugin that checks your gmail atom feed (for unread messages) on regular intervals that you define, and parses it such that it saves the latest email and uses that as a comparison point for the next interval run of the script. It then counts and displays only the new message count of emails that have appeared since the last run. It also uses icons to display the status of new messages (yes or no) along with a count and on click will execute thunderbird.

#!/bin/bash
#   GMAIL New Mail Notifier (new as of last check - not unread)
#   
#   Requires: curl xfce4-genmon-plugin
#   Description: This script downloads your gmail atom feed (unread inbox items) and does the following:
#       1. Saves the atom feed for processing to /tmp/.gmail
#       2. reads in the anchor email from /tmp/.gmail.anchor
#       3. gets and saves to /tmp/gmail.anchor the latest message from the newly downloaded atom feed for next iteration processing
#       4. creates a list of unread emails
#       5. iterates through this list comparing the message to the anchor message
#       6.      if not the same email as the anchor, increment the count of new emails by 1
#       7.      if the same as the anchor, break out of the loop (we have the final count of new emails)
#       8. prepare the genmon output to display the count of new emails since the last check
#
#   xfce4-genmon-plugin properties:
#       Command = path to and name of this script (e.g. /usr/local/bin/gmail)
#       Label = optional label before icon (better unchecked)
#       Period = Time in seconds to check for new emails (to run this script)
#       Default Font = (your choice)
#
#   Other configurations:
#       /usr/local/share/yes.png = icon to display if new emails available
#       /usr/local/share/no.png = icon to display if no new emails available

# config - ENTER YOUR INFO HERE
USERNAME=""
PASSWORD=""

# get the saved latest email
ANCHOR="$(cat /tmp/.gmail.anchor)"

# get and save the atom feed
curl -u "$USERNAME":"$PASSWORD" --silent "https://mail.google.com/mail/feed/atom"  > /tmp/.gmail

# get and save the new latest email
LATEST=$(cat /tmp/.gmail | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*id>\(.*\)<\/id>.*/\2 - \1/p" | head -1)
echo "$LATEST" > /tmp/.gmail.anchor
    
# get the list of unread emails
LIST=$(cat /tmp/.gmail | tr -d '\n' | awk -F '<entry>' '{for (i=2; i<=NF; i++) {print $i}}' | sed -n "s/<title>\(.*\)<\/title.*id>\(.*\)<\/id>.*/\2 - \1/p")
    
# loop through all of the unread emails and count only those newer than the anchor    
COUNT=0
while IFS= read -r line
do
    if [ "$line" == "$ANCHOR" ]; then
        break
    else
        let "COUNT+=1"
    fi
done <<< "$LIST"

##### genmon processing (changes icon if COUNT>1, displays number of new unread emails, executes thunderbird on click)

#set default icon file to no new emails
ICON_FILE=/usr/local/share/no.png 

if [ $COUNT -gt 0 ]; then
    # set icon file to new emails image
    ICON_FILE=/usr/local/share/yes.png
fi

# do the genmon
echo "<img>$ICON_FILE</img> <txt>$COUNT</txt><click>thunderbird</click>"

exit 0

Make sure you add your username and password in the appropriate fields in the script. Instructions for setting up the genmon plugin are in the comments at the top of the script.

Note: The first run of the script will show all unread messages because no anchor point has been created. Simply right-click the plugin, select properties and click close to force it to re-run manually.

Not sure if this is what you have in mind because its not quite clear what you consider to be "new" emails. With this option, the interval you specify defines the window that counts as new.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2016-03-02 01:14:41

ac220
Member
Registered: 2016-02-29
Posts: 4

Re: [SOLVED] need a mail checker with a very specific feature...

Yes, that's exactly what I had in mind, thanks for actually writing the script and good comments. smile

My bash-fu is a bit rusty, but I think I can modify it to my taste if I need to, now that I've seen how it's supposed to work.

Last edited by ac220 (2016-03-02 01:32:37)

Offline

#6 2016-03-02 10:21:47

ac220
Member
Registered: 2016-02-29
Posts: 4

Re: [SOLVED] need a mail checker with a very specific feature...

Well, this script does reset the latest mail every time genmon calls it, which isn't quite what I had in mind. I started to modify it so that it would do it on genmon click instead, but then I got an even simpler idea.

Just putting the Gmail feed url it into any atom feed reader would give me everything I need, since I really treat that inbox as a kind of newsfeed anyway.

Offline

Board footer

Powered by FluxBB