The officially official Devuan Forum!

You are not logged in.

#1 2021-06-30 14:13:26

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

[SOLVED] System mail notifications script

Hello:

My recent dealings with exim 4.94.2 made me realise that I only find out about system mails if/when I open a terminal and check.

Anyone know of a script that would do this automatically everytime I log into my desktop environment?
ie: open a terminal, centered and of a predetermined size informing me that I have mail in my /var/mail/user folder that will inform me of the folder's status: mail or no mail.

Something as simple (?) as a well written script.
Not an application.

Thanks in advance,

A.

Offline

#2 2021-07-01 09:17:00

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: [SOLVED] System mail notifications script

mailcheck package is still around (`apt show mailcheck`), used to be default in debian iirc..it's orphaned now, but still works afaik.

maybe this can help : https://wiki.debian.org/MaildirConfiguration

Offline

#3 2021-07-01 11:31:36

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

xinomilo wrote:

mailcheck package is still around ...

Yes, late last night I found the irssi-scripts package which (among a huge lot of scripts) has this:

mailcheck_imap -- staturbar item which indicates how many new emails
mailcheck_mbox_flux -- polls your unix mailbox for new mail
mailcheck_pop3_kimmo -- POP3 new mail notificationalong with

Neat!

I'll have a look at the one you suggest.
I only want something for the MTA.

xinomilo wrote:

I'll have a look at it.

Thank you very much for the heads up.

Cheers,

A.

Last edited by Altoid (2021-07-01 14:36:23)

Offline

#4 2021-07-01 12:30:05

xinomilo
Unknown
Registered: 2017-07-02
Posts: 315  

Re: [SOLVED] System mail notifications script

Altoid wrote:

I only want something for the MTA.

i think you just need an mda for local delivery (& mailutils provides one, iirc) .
personally, i'm using msmtp-mta to forward any local cron/other emails to my regular email address hosted online. but i never used msmtp for local delivery, not sure it works that way(?).. it's just much lighter than running a full featured MTA like exim4/postfix.

Offline

#5 2021-07-01 12:50:57

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

xinomilo wrote:

i think you just need ...

What I already have installed: exim 4.94.2.  8^D
Sorry, I was not explicit enough about it.

If interested, you can read about my dealings with it here:   https://dev1galaxy.org/viewtopic.php?id=4379
The last post in the thread sums it up in tl;tr: style.

I don't need to forward local mail anywhere, just be notified when mail arrives in my /var/mail/user folder.
Not necessarily in real time (would be nice) just anytime I log in to my desktop.

My box in not up 24/7 and I boot 3 or 4 times a day, so anytime I log in should suffice.

Thanks for your input.

A.

Last edited by Altoid (2021-07-01 12:55:01)

Offline

#6 2021-07-02 01:47:40

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

Altoid wrote:

... something for the MTA.

I think I found something.
As it usually happens, a nice simple application which works.

It is called coolmail and it is in the Devuan repository.

groucho@devuan:~$ apt list | grep coolmail

coolmail/stable,now 1.3-12+b1 amd64 [installed]
coolmail/stable 1.3-12+b1 i386
groucho@devuan:~$ 

You set it up to run at boot from then on it will poll the mail folder (/var/mail/user or a different one).
The polling interval can be set, the default is 20s but I don't know how high this can go.
For me 600s would be just fine.

If there's mail, coolmail will pop up a notification icon and sound the system beep when something arrives.

You can choose an audio file instead of the system beep.

There's a rather cheesy fluttering penguin (like a dumb cartoon) for the default notification icon but you can use a mailbox with a flag that moves. 
Fortunately, you can limit the flag's movement and my guess is that the mailbox icon can also be changed for something else.

The good thing is that you can also fire up an application when you double-click on the notification icon.
I choose to open xterm because I never use it, with a geometry to suit my needs.
And because the next thing would be to add a command to execute mail when the xterm window opens. 

So the coolmail command would be like this:

coolmail -e xterm -geometry 120x15-300+150 -fr 0 -int 20

I'd like to have a title for the xterm window, so I searched on how to do that and found this ...

xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T "System mail notification"

... which gets me an xterm window with the legend "System mail notification" in the tile bar.

The problem is that I am not being able to fit that command line into the coolmail launch command line.

In the command line options it says:

OPTIONS
    -e command
        Use the specified command to launch your mail utility.  Command is a string, and should be in quotes if it contains spaces.

So I write it up like this, placing the command in quotes because it has spaces:

groucho@devuan:~$ coolmail -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T "System mail notification"" -geometry 120x15-300+150
Unknown argument: mail
Type coolmail -h for help.
groucho@devuan:~$ 

Any idea as to how to merge these two commands so they will work?

The next thing woud be to add the command mail to show me what's up.

But this is script sorcery ...   8^|

Thanks in advance,

A.

Offline

#7 2021-07-02 02:03:40

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 1,106  

Re: [SOLVED] System mail notifications script

To use double-quotes within a double-quoted string, they must be back-slashed... ie

coolmail -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T \"System mail notification\"" -geometry 120x15-300+150

An alternative is to use single-quotes, as in the -xrm detail.

Offline

#8 2021-07-02 10:51:48

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

ralph.ronnquist wrote:

... double-quotes within a double-quoted string, they must be back-slashed... ie

coolmail -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T \"System mail notification\"" -geometry 120x15-300+150

An alternative is to use single-quotes, as in the -xrm detail.

As you indicate, with the back-lash or with the single-quotes it worked.
I did have to move the last double quote to the end of the stanza. otherwise the -geometry bit ie: 120x15 would act upon the application's icon and reduce it to a slit with what would seem to be a 120x15 size ratio.

coolmail -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'System mail notification' -geometry 120x15-300+150"

The ideal thing would be to have xterm execute mail/mailx as the window opens, but adding && mail does not work, whether I move the last double quote to the end or not.

More sorcery ... 8^|

How can I get that done?

Thanks a lot for your input.

Best,

A.

Offline

#9 2021-07-02 13:27:14

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 1,106  

Re: [SOLVED] System mail notifications script

yes; add the -e mail option for xterm as its last argument within the double-quoted string. Then that will be run instead of a command shell.

Offline

#10 2021-07-02 14:26:40

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

ralph.ronnquist wrote:

... add the -e mail option for xterm as its last argument within the double-quoted string. Then that will be run instead of a command shell.

If I use this stanza ...

groucho@devuan:~$ coolmail -v -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'System mail notification' -geometry 120x15-300+150 mail"
Coolmail 1.3 watching file: /var/spool/mail/groucho
^C
groucho@devuan:~$ 

... clicking on the icon gets me nothing instead of the xterm window.

If I use this stanza ...

groucho@devuan:~$ coolmail -v -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'System mail notification' -geometry 120x15-300+150 /var/alternatives/mail"
Coolmail 1.3 watching file: /var/spool/mail/groucho
xterm: No absolute path found for shell: /var/alternatives/mail
^C
groucho@devuan:~$ 

... is the same, save for the output (because of -v).

I found some more information here:  http://www.linuxcertif.com/man/1/coolmail/

X DEFAULTS
This program understands the core resource names and classes as well as:

frameCount (class FrameCount)
    Specifies the number of frames to be generated per animation.
inbox (class Inbox)
    Specifies the mail inbox that coolmail will watch.

mailCommand (class MailCommand)                                                               |  <---
    Specifies the command that should be launched to read and write mail.    |  <---

monochrome (class Monochrome)
    A Boolean value that enables monochrome mode when true.
soundFile (class SoundFile)
    Specifies the audio file to use rather than the standard system beep.
volume (class Volume)
    Value between 0 and 100 for the volume setting for both the system beep and the sound file.

As far as I know, the mailCommand can be Mail, mail or mailx ie: the ones present in /etc/alternatives, but as they are all linked to /usr/bin/bsd-mailx, I also tried this:

coolmail -v -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'System mail notification' -geometry 120x15-300+150 /usr/bin/bsd-mailx"

No cigar ... 8^|

Thanks for your input.

Best,

A.

Last edited by Altoid (2021-07-02 17:53:38)

Offline

#11 2021-07-02 23:41:44

ralph.ronnquist
Administrator
From: Clifton Hill, Victoria, AUS
Registered: 2016-11-30
Posts: 1,106  

Re: [SOLVED] System mail notifications script

mmm you omitted the -e... the last part of the line should read

-geometry 120x15-300+150 -e mail"

at least that's what the man xterm page says. I don't really know what the significant difference is between nominating a shell at the end (without -e) and nominating a program via the -e option. The man page has some discussion about it, but the authors' idea of clarity is different from mine.

Offline

#12 2021-07-03 01:45:57

Altoid
Member
Registered: 2017-05-07
Posts: 1,415  

Re: [SOLVED] System mail notifications script

Hello:

ralph.ronnquist wrote:

mmm you omitted the -e...

I was convinced I had tried it with and without that -e there, so I checked again.
I was/was not mistaken: the catch is that xterm will open only if there's unread mail.

Clicking on the application icon when it shows mailbox flag in the 'down' position will not open xterm

So ...

coolmail -v -e "xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T 'System mail notification' -geometry 120x15-300+150 -e mail"

... works as expected.

I had spent a whole afternoon atempting various combinations, I actually got it to work ...
... but not with mail.

I opened up the configuration file /etc/X11/app-defaults/Coolmail and edited some of the default settings to be able to simplify the command stanza.

groucho@devuan:~$ cat /etc/X11/app-defaults/Coolmail
! Coolmail Application Defaults
!
coolmail.soundFile: /usr/local/bin/sounds/ding.au
!coolmail.frameCount: 10
!coolmail.inbox: /var/spool/mail/username
coolmail.mailCommand: xterm -geometry 120x15-300+150 -e mutt
coolmail.monochrome: False
coolmail*geometry: 76x84-1875+350
coolmail.volume: 100
groucho@devuan:~$ 

With that configuration file I can start up Coolmail in a terminal with :~$coolmail -v.
The application's icon shows up as expected and ~30s after I send myself mail from another terminal, the icon changes.

Clicking on the icon opens up xterm with mutt and I can process the new mail.
Problem is I really don't like mutt and (for the time being), I only need to read my system mail.
I won't be sending mail to anyone, so a terminal with mail is quite enough.

With your heads up, I edited the configuration file to coolmail.mailCommand: xterm -geometry 120x15-300+150 -e mail and now I can say it works.
I worked before but I assumed it did not. 

As expected, I get an xterm window, with the mail label which will do well enough.   
Thanks for that, it did not occurr to me there could be a different behaviour when clicking on the application's icon.

As the system beep set at 100 by coolmail.volume is not loud enough and also confusing, I tried using a *.wav file but I got a "Problem opening/dev/audio" error.
I looked for /dev/audio but it is not there.

groucho@devuan:~$ ls -l /dev/audio
ls: cannot access '/dev/audio': No such file or directory
groucho@devuan:~$

I then converted the file to *.au but got the same result.

The thing is that this really cool application is quite dated.
It was copyrighted back in 1994, so it uses OSS drivers which were dropped from the Linux kernel not too long ago (4.15?).

So I installed the aoss package. https://alsa.opensrc.org/Aoss

With that package installed, starting the application with aoss would solve the sound issue.
But no ...

groucho@devuan:~$ aoss coolmail -v
Coolmail 1.3 watching file: /var/spool/mail/groucho
Coolmail: Error writing to /dev/audio.
groucho@devuan:~$ 

Now, instead of not being able to open /dev/audio it cannot write to /dev/audio.
Thank you for helping me make some headway here.

The only thing pending is getting some audio output from Coolmail.

Best,

A.

... the authors' idea of clarity is different from mine.

A quotable quote if there ever was one.

Offline

Board footer