Unread mail count from qdbus

Daniel Vrátil dvratil at kde.org
Mon Oct 17 07:26:24 BST 2016


On Monday, October 17, 2016 1:06:55 AM CEST Aleix Pol wrote:
> On Sun, Oct 16, 2016 at 8:59 PM, Daniel Vrátil <dvratil at kde.org> wrote:
> > On Sunday, October 16, 2016 7:50:46 PM CEST CoD wrote:
> >> Hi everyone,
> > 
> > Hi,
> > 
> >> I'm trying to retrieve the number of unread mails in kmail/akonadi from a
> >> bash script but I'm having troubles understanding qdbus.
> >> 
> >> I'm looking for something simple: I'd be happy even with a "boolean"
> >> answer
> >> such as "yes there are new mails" or "no, nothing new".
> >> 
> >> I have many accounts, both imap and local, but I need just to know if one
> >> of them has unread emails.
> >> 
> >> I've explored qdbus a bit but I can't figure out neither if I should call
> >> akonadi or kmail nor what's the right method to call, so I decided to
> >> bother you... sorry for that ;-)
> > 
> > Unfortunatelly right now there is no API to get such information via DBus
> > or command line.
> > 
> > The only chance for you right now is to write a tiny utility using the
> > Akonadi C++ API to retrieve the information. Just let me know if you want
> > some hints on how to do this, it would not be more than ~20 lines of C++.
> > 
> > Dan
> > 
> >> Any help is appreciated :-)
> >> 
> >> Thank you
> >> 
> >> CoD
> > 
> 
> Maybe it's available from the status notifier?

Good point. There is 

qdbus org.kde.StatusNotifierItem-$(pidof kmail)-1 /StatusNotifierItem 
org.kde.StatusNotifierItem.Status

which would return "Active" if there are unread emails. Unfortunately this 
will only work reliably with current git master (and since Apps 16.12), in 
current stable release it cannot be relied on.

Also it requires KMail to be running and have systray enabled

Dan

> 
> Aleix


-- 
Daniel Vrátil
www.dvratil.cz | dvratil at kde.org
IRC: dvratil on Freenode (#kde, #kontact, #akonadi, #fedora-kde)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20161017/a92c1cd0/attachment.sig>


More information about the kde-pim mailing list