Hi all geeks, I have created a polybar module for pop3 mail checking but I think there’s something wrong with my script because when there is no unread mail in my “inbox” I get the output “1”.
Here are the module and the script:
I use imap to check both my Gmail and provider account. The overall checking process is much the same. Without getting into the complexities of setting up mutt/imap/etc - the crux of the biscuit is simply this:
my pb-mail script:
# Simple script that gathers new mail from locl directories.
# This works perfectly if you pull down emails from imap accounts.
du -a ~/.mutt/.mail/*/Inbox/new/* 2>/dev/null | wc -l
This is the only line I have in my mail checker script. Nothing else.
The mail module for my polybar:
type = custom/script
exec = pb-mail
label-padding = 1
format-prefix =" "
click-left = st -e neomutt &
click-right = st -e neomutt &
I dont suspect the mail agent makes a diff - its the dirs you want to monitor for an increase or decrease in the mail items and the command to use to do that…
The du command (IIRC) allows for the the 0 you are seeking.
Of course, if you are not checking mails that may be local (via imap or some other app that pulls pop mail local), then my script is useless.
I have to say that I don’t use a gmail account so I have of course changed the imap server adress and also tried port 143 (less secure) but I still have the message in polybar, this script works fine by launching it the terminal, no warning message and a real state of my inbox indeed.
To get my shell script telling the “thruth” I have to let 1 mail in so when I receive a new one the polybar module tells me I have 2 mails inside . I consider that the issue isn’t solved but I do use it like this anyway till I find the solution or someone else. Thanks guys.