搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

How to count unread messages from bash script?

  • 6 回覆
  • 1 有這個問題
  • 7 次檢視
  • 最近回覆由 wognatn

more options

Hello,

I would like to write a bash script to count new, unread emails, to show in conky. Apparently in the past,

grep -c "X-Mozilla-Status: 0000" /path/to/INBOX

worked, but no longer: INBOX file does not change when a new message is read. The corresponding INBOX.msf does, but the changes are pretty incomprehensible. Is there an unread message tag there that I could grep?

Or is there another way to find number of unread messages?

Thanks in advance.

MXLinux 17.1, Thunderbird 60.3.1

Hello, I would like to write a bash script to count new, unread emails, to show in conky. Apparently in the past, grep -c "X-Mozilla-Status: 0000" /path/to/INBOX worked, but no longer: INBOX file does not change when a new message is read. The corresponding INBOX.msf does, but the changes are pretty incomprehensible. Is there an unread message tag there that I could grep? Or is there another way to find number of unread messages? Thanks in advance. MXLinux 17.1, Thunderbird 60.3.1

由 wognatn 於 修改

所有回覆 (6)

more options

If the account is IMAP and the account setting are not to store messages on this machine then there is no inbox file.

MSF files are in MORK format and ostensibly can be read with a script, but the effort would be significantly more that an unread email count is worth I would think.

more options

Matt said

the effort [to read msf file] would be significantly more that an unread email count is worth I would think.
Thanks, Matt. A little reading on MORK format convinces me you're right.
more options

wognatn said

Matt said
the effort [to read msf file] would be significantly more that an unread email count is worth I would think.
Thanks, Matt. A little reading on MORK format convinces me you're right.

MORK is also the format of the address book files That was my conclusion when I tried to extract information from them.

more options

I have a working check for new messages. As predicted, it was more effort than it was worth. In the unlikely event that anyone is interested ;) I'd welcome improvements and corrections.

It seems that unread messages result in a tag (^94=1) near the end of INBOX.msf. When any new message in that inbox is read or previewed, (^94=0) is appended. So the following works for me to check for new messages:

[loop over all accounts] tac /path/to/INBOX.msf | grep -m 1 '(^94=.)' | grep -v '(^94=0)' && [new mail action]

由 wognatn 於 修改

more options

This is useful.

Any pointers to articles on how to make this part of my local setup (I'm on Win 10...) It would be a bit of a hack to get Msys2 + minnty etc to do all that.

I'm yet to dive into scripting/macros/aliasing (etc) for Thunderbird

more options

I found no documentation, it's all trial and error based on Matt's answer above. There's a little more detail here.