Query unread emails count from Thunderbird via terminal











up vote
1
down vote

favorite












I want to add to i3 status bar indicator showing number of unread emails in Thunderbird profile. Since Thunderbird itself doesn't have command-line options to get that info, I've tried to query it's database using X-Mozilla-Status code:



$ grep 'X-Mozilla-Status:' ~/.thunderbird/<profile>/ImapMail/<email>/INBOX


But it appears that all messages has the same status code (there is no difference whether message unread or not):



X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000


Is there are any other way to build a script get total/unread emails count statistics?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I want to add to i3 status bar indicator showing number of unread emails in Thunderbird profile. Since Thunderbird itself doesn't have command-line options to get that info, I've tried to query it's database using X-Mozilla-Status code:



    $ grep 'X-Mozilla-Status:' ~/.thunderbird/<profile>/ImapMail/<email>/INBOX


    But it appears that all messages has the same status code (there is no difference whether message unread or not):



    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000


    Is there are any other way to build a script get total/unread emails count statistics?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to add to i3 status bar indicator showing number of unread emails in Thunderbird profile. Since Thunderbird itself doesn't have command-line options to get that info, I've tried to query it's database using X-Mozilla-Status code:



      $ grep 'X-Mozilla-Status:' ~/.thunderbird/<profile>/ImapMail/<email>/INBOX


      But it appears that all messages has the same status code (there is no difference whether message unread or not):



      X-Mozilla-Status: 0001
      X-Mozilla-Status2: 00000000


      Is there are any other way to build a script get total/unread emails count statistics?










      share|improve this question













      I want to add to i3 status bar indicator showing number of unread emails in Thunderbird profile. Since Thunderbird itself doesn't have command-line options to get that info, I've tried to query it's database using X-Mozilla-Status code:



      $ grep 'X-Mozilla-Status:' ~/.thunderbird/<profile>/ImapMail/<email>/INBOX


      But it appears that all messages has the same status code (there is no difference whether message unread or not):



      X-Mozilla-Status: 0001
      X-Mozilla-Status2: 00000000


      Is there are any other way to build a script get total/unread emails count statistics?







      command-line i3 thunderbird






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 11 at 16:57









      anlar

      8721618




      8721618






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          I hope the results of some experiments are useful. (Tbird 60.3.1, MX-Linux 17.1) As anlar said, the INBOX file changes when a message is received but not when it is previewed or read. The corresponding INBOX.msf, which is in incomprehensible mork format, records such actions.



          A tag (^94=1) is added to INBOX.msf when a new message is received and (^94=0) is appended when a previously unread message is read or previewed. Therefore, if



          grep '(^94=.)' /home/user/.thunderbird/profile-name/ImapMail/imap.account.com/INBOX.msf | tail -1



          shows (^94=1), there is at least one new message on that account. If (^94=0) then the last action was to read or preview a new message; there may still be unread messages, though. (Edit: corrected file name)



          This is only trial and error, but a script based on it (new msg detector only, no count) is working well so far :) (see this question on Mozilla forum.)



          Added:



          msf file fields are listed at the beginning; among them are
          (A1=numMsgs)(A2=numNewMsgs). It's not clear how to use this to get a count. For example, this account has 3 new messages:



          grep -n '(^A2=.)' INBOX.msf
          432: (^A8^85)(^B5=50)(^A1=20)(^A2=2)(^A6=50)(^BD^77A)(^C4=12)(^C5=2)
          433: (^C6=0)(^C7=0)(^C9^5B0)(^C8^A0)(^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]}
          480: (^B0=1)(^88^83)(^B1=222)(^B2^84)(^A8^85)(^B5=50)(^A1=21)(^A2=3)
          482: (^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]


          Maybe someone who knows mork could explain how to extract the right number?






          share|improve this answer






























            up vote
            0
            down vote













            From this article:




            Thunderbird doesn't have a scripting capability.




            The same article actually recommends reading from the mailbox files directly, checking the X-Mozilla-Status as you're already doing (and apparently not really working as expected.) See that article for more pointera on the X-Mozilla-Status header and the mbox format, to double check that what you're doing is matching their instructions.



            Another possibility is that you're using IMAP from Thunderbird and it behaves differently in that case. IMAP has special flags (such as Seen to track message status and it's possible Thunderbird is caching and processing those, so maybe look for them too. If you're using IMAP, another option is to use a separate IMAP client to query the server directly (you'll find IMAP bindings for most common scripting languages.) This approach has the disadvantage that you'll use the network for this check and also you'll have to manage and store credentials.






            share|improve this answer





















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "106"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481111%2fquery-unread-emails-count-from-thunderbird-via-terminal%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote













              I hope the results of some experiments are useful. (Tbird 60.3.1, MX-Linux 17.1) As anlar said, the INBOX file changes when a message is received but not when it is previewed or read. The corresponding INBOX.msf, which is in incomprehensible mork format, records such actions.



              A tag (^94=1) is added to INBOX.msf when a new message is received and (^94=0) is appended when a previously unread message is read or previewed. Therefore, if



              grep '(^94=.)' /home/user/.thunderbird/profile-name/ImapMail/imap.account.com/INBOX.msf | tail -1



              shows (^94=1), there is at least one new message on that account. If (^94=0) then the last action was to read or preview a new message; there may still be unread messages, though. (Edit: corrected file name)



              This is only trial and error, but a script based on it (new msg detector only, no count) is working well so far :) (see this question on Mozilla forum.)



              Added:



              msf file fields are listed at the beginning; among them are
              (A1=numMsgs)(A2=numNewMsgs). It's not clear how to use this to get a count. For example, this account has 3 new messages:



              grep -n '(^A2=.)' INBOX.msf
              432: (^A8^85)(^B5=50)(^A1=20)(^A2=2)(^A6=50)(^BD^77A)(^C4=12)(^C5=2)
              433: (^C6=0)(^C7=0)(^C9^5B0)(^C8^A0)(^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]}
              480: (^B0=1)(^88^83)(^B1=222)(^B2^84)(^A8^85)(^B5=50)(^A1=21)(^A2=3)
              482: (^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]


              Maybe someone who knows mork could explain how to extract the right number?






              share|improve this answer



























                up vote
                2
                down vote













                I hope the results of some experiments are useful. (Tbird 60.3.1, MX-Linux 17.1) As anlar said, the INBOX file changes when a message is received but not when it is previewed or read. The corresponding INBOX.msf, which is in incomprehensible mork format, records such actions.



                A tag (^94=1) is added to INBOX.msf when a new message is received and (^94=0) is appended when a previously unread message is read or previewed. Therefore, if



                grep '(^94=.)' /home/user/.thunderbird/profile-name/ImapMail/imap.account.com/INBOX.msf | tail -1



                shows (^94=1), there is at least one new message on that account. If (^94=0) then the last action was to read or preview a new message; there may still be unread messages, though. (Edit: corrected file name)



                This is only trial and error, but a script based on it (new msg detector only, no count) is working well so far :) (see this question on Mozilla forum.)



                Added:



                msf file fields are listed at the beginning; among them are
                (A1=numMsgs)(A2=numNewMsgs). It's not clear how to use this to get a count. For example, this account has 3 new messages:



                grep -n '(^A2=.)' INBOX.msf
                432: (^A8^85)(^B5=50)(^A1=20)(^A2=2)(^A6=50)(^BD^77A)(^C4=12)(^C5=2)
                433: (^C6=0)(^C7=0)(^C9^5B0)(^C8^A0)(^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]}
                480: (^B0=1)(^88^83)(^B1=222)(^B2^84)(^A8^85)(^B5=50)(^A1=21)(^A2=3)
                482: (^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]


                Maybe someone who knows mork could explain how to extract the right number?






                share|improve this answer

























                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote









                  I hope the results of some experiments are useful. (Tbird 60.3.1, MX-Linux 17.1) As anlar said, the INBOX file changes when a message is received but not when it is previewed or read. The corresponding INBOX.msf, which is in incomprehensible mork format, records such actions.



                  A tag (^94=1) is added to INBOX.msf when a new message is received and (^94=0) is appended when a previously unread message is read or previewed. Therefore, if



                  grep '(^94=.)' /home/user/.thunderbird/profile-name/ImapMail/imap.account.com/INBOX.msf | tail -1



                  shows (^94=1), there is at least one new message on that account. If (^94=0) then the last action was to read or preview a new message; there may still be unread messages, though. (Edit: corrected file name)



                  This is only trial and error, but a script based on it (new msg detector only, no count) is working well so far :) (see this question on Mozilla forum.)



                  Added:



                  msf file fields are listed at the beginning; among them are
                  (A1=numMsgs)(A2=numNewMsgs). It's not clear how to use this to get a count. For example, this account has 3 new messages:



                  grep -n '(^A2=.)' INBOX.msf
                  432: (^A8^85)(^B5=50)(^A1=20)(^A2=2)(^A6=50)(^BD^77A)(^C4=12)(^C5=2)
                  433: (^C6=0)(^C7=0)(^C9^5B0)(^C8^A0)(^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]}
                  480: (^B0=1)(^88^83)(^B1=222)(^B2^84)(^A8^85)(^B5=50)(^A1=21)(^A2=3)
                  482: (^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]


                  Maybe someone who knows mork could explain how to extract the right number?






                  share|improve this answer














                  I hope the results of some experiments are useful. (Tbird 60.3.1, MX-Linux 17.1) As anlar said, the INBOX file changes when a message is received but not when it is previewed or read. The corresponding INBOX.msf, which is in incomprehensible mork format, records such actions.



                  A tag (^94=1) is added to INBOX.msf when a new message is received and (^94=0) is appended when a previously unread message is read or previewed. Therefore, if



                  grep '(^94=.)' /home/user/.thunderbird/profile-name/ImapMail/imap.account.com/INBOX.msf | tail -1



                  shows (^94=1), there is at least one new message on that account. If (^94=0) then the last action was to read or preview a new message; there may still be unread messages, though. (Edit: corrected file name)



                  This is only trial and error, but a script based on it (new msg detector only, no count) is working well so far :) (see this question on Mozilla forum.)



                  Added:



                  msf file fields are listed at the beginning; among them are
                  (A1=numMsgs)(A2=numNewMsgs). It's not clear how to use this to get a count. For example, this account has 3 new messages:



                  grep -n '(^A2=.)' INBOX.msf
                  432: (^A8^85)(^B5=50)(^A1=20)(^A2=2)(^A6=50)(^BD^77A)(^C4=12)(^C5=2)
                  433: (^C6=0)(^C7=0)(^C9^5B0)(^C8^A0)(^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]}
                  480: (^B0=1)(^88^83)(^B1=222)(^B2^84)(^A8^85)(^B5=50)(^A1=21)(^A2=3)
                  482: (^A4^760)(^A2=0)(^A2=0)(^A2=0)(^AA=0)]


                  Maybe someone who knows mork could explain how to extract the right number?







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Dec 8 at 1:47

























                  answered Dec 7 at 20:47









                  wognath

                  212




                  212
























                      up vote
                      0
                      down vote













                      From this article:




                      Thunderbird doesn't have a scripting capability.




                      The same article actually recommends reading from the mailbox files directly, checking the X-Mozilla-Status as you're already doing (and apparently not really working as expected.) See that article for more pointera on the X-Mozilla-Status header and the mbox format, to double check that what you're doing is matching their instructions.



                      Another possibility is that you're using IMAP from Thunderbird and it behaves differently in that case. IMAP has special flags (such as Seen to track message status and it's possible Thunderbird is caching and processing those, so maybe look for them too. If you're using IMAP, another option is to use a separate IMAP client to query the server directly (you'll find IMAP bindings for most common scripting languages.) This approach has the disadvantage that you'll use the network for this check and also you'll have to manage and store credentials.






                      share|improve this answer

























                        up vote
                        0
                        down vote













                        From this article:




                        Thunderbird doesn't have a scripting capability.




                        The same article actually recommends reading from the mailbox files directly, checking the X-Mozilla-Status as you're already doing (and apparently not really working as expected.) See that article for more pointera on the X-Mozilla-Status header and the mbox format, to double check that what you're doing is matching their instructions.



                        Another possibility is that you're using IMAP from Thunderbird and it behaves differently in that case. IMAP has special flags (such as Seen to track message status and it's possible Thunderbird is caching and processing those, so maybe look for them too. If you're using IMAP, another option is to use a separate IMAP client to query the server directly (you'll find IMAP bindings for most common scripting languages.) This approach has the disadvantage that you'll use the network for this check and also you'll have to manage and store credentials.






                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          From this article:




                          Thunderbird doesn't have a scripting capability.




                          The same article actually recommends reading from the mailbox files directly, checking the X-Mozilla-Status as you're already doing (and apparently not really working as expected.) See that article for more pointera on the X-Mozilla-Status header and the mbox format, to double check that what you're doing is matching their instructions.



                          Another possibility is that you're using IMAP from Thunderbird and it behaves differently in that case. IMAP has special flags (such as Seen to track message status and it's possible Thunderbird is caching and processing those, so maybe look for them too. If you're using IMAP, another option is to use a separate IMAP client to query the server directly (you'll find IMAP bindings for most common scripting languages.) This approach has the disadvantage that you'll use the network for this check and also you'll have to manage and store credentials.






                          share|improve this answer












                          From this article:




                          Thunderbird doesn't have a scripting capability.




                          The same article actually recommends reading from the mailbox files directly, checking the X-Mozilla-Status as you're already doing (and apparently not really working as expected.) See that article for more pointera on the X-Mozilla-Status header and the mbox format, to double check that what you're doing is matching their instructions.



                          Another possibility is that you're using IMAP from Thunderbird and it behaves differently in that case. IMAP has special flags (such as Seen to track message status and it's possible Thunderbird is caching and processing those, so maybe look for them too. If you're using IMAP, another option is to use a separate IMAP client to query the server directly (you'll find IMAP bindings for most common scripting languages.) This approach has the disadvantage that you'll use the network for this check and also you'll have to manage and store credentials.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 11 at 18:15









                          Filipe Brandenburger

                          6,8652733




                          6,8652733






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481111%2fquery-unread-emails-count-from-thunderbird-via-terminal%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Morgemoulin

                              Scott Moir

                              Souastre