搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

How to count unread messages from bash script?

  • 6 个回答
  • 1 人有此问题
  • 17 次查看
  • 最后回复者为 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.