WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Creating a new notification system for an E-mail client  (Read 90 times)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12807
Creating a new notification system for an E-mail client
« on: May 31, 2026, 07:58:25 PM »
I've been using Thunderbird as my email client for over 4 years now and
overall I'm pretty content with it. There are a few little things about
it that do annoy me. When it pops up an E-mail notification, it places
it in the lower right corner of my screen and covers my clock. Searching
online suggests Thunderbird does not have a setting to change where the
the pop up gets placed. Also, if I want to leave the pop up on my screen
as a reminder for later, it can't be dragged to a new location. Plus it
has a maximum display time of 1 hour, after that, Thunderbird closes it.

So I decided to try to create an alternative. My design goals included:
1. Notifications that would pop up where I wanted them to.
2. Notifications that I could drag to a new location.
3. Notifications that are 3 lines high:
   Account-gmail.com - Timestamp (titlebar)
   From: Text
   Subject: Text
4. Notifications that automatically widen for longer From/Subject lines.
5. Notifications that included a timestamp of when the email was downloaded.

I feel I've achieved those goals with one bonus, the desktops popup menu now
displays the notifications  "Account-gmail.com - Timestamp"  line.

This is the old Thunderbird notification in the lower right corner of my screen:



You can just see part of the light blue background of my clock peeking out
from behind the lower right corner of the notification.

This is the new notification in the upper right corner of my screen:



By using several options to block keyboard input, suppress the command
prompt, hiding the cursor, and setting size and location, i was able to
use aterm as a notification pop up. To the left you can see it listed in the
desktop menu.

The script I wrote depends on perl5, inotify, xdotool, and aterm. All testing
was done with flwm_topside as the window manager.

How it works:
 1. If it doesn't exist, a short perl script is created in "$HOME/.local/bin/".
 2. A named pipe ("$Queue") is created for reporting email arrivals to the script.
 3. A copy of inotifywait is launched in the background monitoring inboxes.
 4. The script blocks while waiting for a message to show up in "$Queue".
 5. When an email arrives, inotifywait writes the Path/Filename to "$Queue".
 6. The script translates Path to an email address and saves it ("$To").
 7. The titlebar for aterm is created, Title="$To - $CurrentDate".
 8. "^From: " and "^Subject: " strings are extracted from email.
 9. Test/decode the strings if required.
10. Adjust default terminal width for a longer string if required.
11. Export From and Subject so the child process will see it.
12. Get the window ID of the window that currently has focus.
13. Launch the terminal informing us of the email.
14. Launching the terminal steals focus, so we return it to the previous owner.
15. Go to step 4.


Just a few more comments:
1. The email addresses in the script and images are not real. I made them up.
2. FLWM does not display @ unless entered as @@, so @ was replaced with -. See also:
   https://forum.tinycorelinux.net/index.php?topic=28151.0
3. Email1, Email2, and Email3 at the start of the script are the inboxes being monitored.
4. Limited testing was done with rxvt:
   -fade is opposite of aterm. Set it to 0, not 100.
   rxvt defaults to black text on white background instead of the opposite way around.
5. Currently the script handles base64, quoted printable, and UTF-8 encoded text.
6. The script is fairly well commented, but if something appears unclear, ask a question.
7. A copy of the script is attached to this post.
« Last Edit: June 01, 2026, 09:00:44 AM by Rich »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12807
Re: Creating a new notification system for an E-mail client
« Reply #1 on: June 01, 2026, 09:14:48 AM »
A forum member PMed me with a couple of comments:
Quote
s there supposed to be anything on line number 66? i see a ' (single quote mark?)
Line 66 is correct. Originally I was going to do this:
Code: [Select]
printf "%s" "$QPprint_File" > "${HomeBin}QPprint"Placing the single quote on its own line ensures that the previous
line will contain a newline character.

As it turns out, I used an echo command instead. The result being
an extra newline character at the end of the perl script that function
creates, which is harmless.


Quote
guessing on line 164 the "k" is missing in "Desktop"
Nice catch. It's in one of my comments, but it's been corrected and
a fresh copy attached to the original post.