This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Get unread mail count from Akonadi via CLI (qdbus maybe?)

Tags: None
(comma "," separated)
CoD
Karma
0
I'm trying to configure conky to show an unread mail icon if Kmail has new emails.
I just need a boolean response: nothing too fancy.

THE QUESTION
Is there a way to ask Kmail (or Akonadi) if there are unread emails via command line?

THE SCENARIO
Small desktop with Debian Jessie. Fluxbox as desktop.
Kmail configured with several different akonadi resources, both imap and local. New mails arrive in each inbox folder.

WHAT I DO NOT WANT
I don't want to move all incoming emails in a local folder: I need them where they are.
I do not want to use conky internal system to monitor email boxes: this means new connections to each mailbox and more memory consumption. I'd like to have conky show an icon only if I decide to start kmail and akonadi.

WHAT I'VE ALREADY TRIED (with no success)
- configuring knotify to register events in a text file (does not work because the file is not cleaned after reading emails, so there are always emails awaiting)
- exploring qdbus org.kde.knotify
- exploring qdbus org.kde.kmail methods
- exploring qdbus org.kde.akonadi_newmailnotifier_agent-3027 methods

If I understood well what I read online I should ask akonadi and not kmail for unread emails, but I cannot find the right qdbus syntax to use.

Any help is appreciated :)
CoD
Karma
0
Solved!

I wrote to kde-pim mailing list and they replied me quickly and kindly: great developers have always a word for poor confused users ;D

This is not THE solution, but it's working:
Code: Select all
qdbus --literal org.kde.StatusNotifierItem-$(pidof kontact)-1 /StatusNotifierItem org.freedesktop.DBus.Properties.Get org.kde.StatusNotifierItem ToolTip | cut -b78-88

change kontact with kmail if you are just running kmail.
It will return the tooltip text of the icon in the tray (you should enable it): it's a localized text, so you have to parse it according to your language.

From the current git master (and since Apps 16.12) you'll be able to use:
Code: Select all
qdbus org.kde.StatusNotifierItem-$(pidof kontact)-1 /StatusNotifierItem org.kde.StatusNotifierItem.Status


I'll mark this thread as solved.


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]