Menu

Imap Idle Popup-Notification

Helpdesk
ewigkeit
2014-02-26
2014-02-27
  • ewigkeit

    ewigkeit - 2014-02-26

    Hi Thomas (and community) and thank you very much for the awesome BE:Shell. I'm running Arch Linux and my goal at the moment is, to receive a Popup-Notification, when I receive a new mail. I guess it would work with runnuing thunderbird in the background, but that's overkill. It kind of works with Geary at the moment, but only with the little Infocenter-Notifier pulsing, which is easily overlooked by myself (so the need for a real popup).

    So I ask, if it is possible to configure a trigger for a real popup (i.e. 'kdialog --msgbox "New Mail has arrived'). I guess maybe some Extensions (be.idle.imap / be.watched) could get me a step nearer and I want to give them a try, if nothing else helps, but I can't get them to run. What's necessary to get them up and working?

    Maybe there's an easier solution for my problem, I would appreciate any help. Thanks in advance!

     
  • Thomas Luebking

    Thomas Luebking - 2014-02-26

    Yes, that's possible:
    ~/.config/be.idle.imap.conf

    [General]
    Accounts=GMail, Gmail2
    Exec=/home/ewigkeit/.kde/share/apps/be.shell/scripts/be.mailed %2 %1 %3

    [GMail]
    Server=imap.gmail.com
    Login=ewigkeit
    Password=password

    [GMail]
    Server=imap.gmail.com
    Login=ewigkeitsgirlfriend
    Password=passwordaswell


    The "Exec" can be a random call, using a script is probably a good idea

    --------------- snip --------------

    !/bin/sh

    if (($1 > 1)); then
    MAIL=mails
    else
    MAIL=mail
    fi
    PID=pidof be.shell
    ADDRESS="tr '\0' '\n' < /proc/${PID}/environ | grep DBUS_SESSION_BUS_ADDRESS | cut -d"=" -f2-"
    qdbus --address "$ADDRESS" org.kde.be.shell /trojita setToolTip "$1 new $MAIL @ $2"
    qdbus --address "$ADDRESS" org.kde.be.shell /trojita setText "$3"
    ps -C trojita >/dev/null || mplayer -really-quiet ~/.kde/share/sounds/Hello.mp3

    --------------- / snip --------------------

    Since be.idle.imap is not a GUI process, it won't automatically stop with X11/logging out!
    (Thus if you want to use dbus you've to pick the proper address of the receiver)

    NOTICE: that the imap MSP MUST support IMAP IDLE, (plain) polling is not supported (but could if someone begs a lot ;-), pop3 is not supported at all (and i don't see that happen)
    I'll add IMAP NOTIFY as soon as I see a real server providing it :-(

    $1 is the unseen mails in
    $2 the last updated account
    $3 the amount of all unseen mails

    For details see the README in the be.idle.imap folder.

    be.watched is a generic dbus/exec connector to connect random dbus signals to dbus or exec calls.

     
  • ewigkeit

    ewigkeit - 2014-02-26

    Thanks for your reply, but it still doesn't work. IMAP Idle is working, Trojitá is up and running in the systray, but when a new mail arrives, mails are shown in the inbox but no popup or notification. I tried to narrow it down myself, but I'm definitely overlooking something here and my skills aren't that good, obviously. So I post some of the outputs I got with different trys. At the end I also posted the config I am working with and a modified script (i.e. you need to call explicitly qdbus-qt4 with Arch or set the environment variable accordingly).


    $ /home/ewigkeit/Progs/be.mailed %2 %1 %3
    Progs/be.mailed: Zeile 3: ((: %2 > 1: Syntax Fehler: Operator erwartet. (Fehlerverursachendes Zeichen ist \"%2 > 1\").
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    Could not connect to D-Bus server: org.freedesktop.DBus.Error.BadAddress: Address does not contain a colon
    Could not connect to D-Bus server: org.freedesktop.DBus.Error.BadAddress: Address does not contain a colon


    $ /home/ewigkeit/Progs/be.mailed 1 Mailserver 3
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave.
    Could not connect to D-Bus server: org.freedesktop.DBus.Error.BadAddress: Address does not contain a colon
    Could not connect to D-Bus server: org.freedesktop.DBus.Error.BadAddress: Address does not contain a colon


    $ qdbus-qt4 --address "unix:abstract=/tmp/dbus-mEY6E9GFdn,guid=88c3ea8d86aee6154349d39f530ddc60" org.kde.be.shell /trojita setText "test"
    Cannot find '.setText' in object /trojita at org.kde.be.shell


    ~/.config/be.idle.imap.conf

    [General]
    Accounts=Mailserver
    Exec=/home/ewigkeit/Progs/be.mailed %2 %1 %3

    [Mailserver]
    Server=192.168.0.4 #Selfhosted Postfix/Dovecot
    Login=foo_ewigkeit
    Password=foo_Password
    Port=993 # I picked that up from Lisa Simpson, not necessary


    /home/ewigkeit/Progs/be.mailed

    _ #!/bin/sh

    if (($1 > 1)); then
    MAIL=mails
    else
    MAIL=mail
    fi
    PID=pidof be.shell
    ADDRESS="tr '\0' '\n' < /proc/${PID}/environ | grep DBUS_SESSION_BUS_ADDRESS | cut -d"=" -f2-"
    qdbus-qt4 --address "$ADDRESS" org.kde.be.shell /trojita setToolTip "$1 new $MAIL @ $2"
    qdbus-qt4 --address "$ADDRESS" org.kde.be.shell /trojita setText "$3"
    ps -C trojita >/dev/null || mplayer -really-quiet /home/ewigkeit/Home_Server/MP3/Test.mp3


     
  • Thomas Luebking

    Thomas Luebking - 2014-02-26

    Sh** - markdown completely screwed the script...

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    #!/bin/sh
    if (($1 > 1)); then
       MAIL=mails
    else
       MAIL=mail
    fi
    PID=`pidof be.shell`
    ADDRESS="`tr '\0' '\n' < /proc/${PID}/environ | grep DBUS_SESSION_BUS_ADDRESS | cut -d"=" -f2-`"
    qdbus --address "$ADDRESS" org.kde.be.shell /trojita setToolTip "$1 new $MAIL @ $2"
    qdbus --address "$ADDRESS" org.kde.be.shell /trojita setText "$3"
    ps -C trojita >/dev/null || mplayer -really-quiet ~/.kde/share/sounds/Hello.mp3
    

    Also you need to have a button named "trojita" in be.shell to use the dbus calls to control it (whether trojita is running or not does not matter) - the script was just (my) example.

    You can of course also just run
    kdialog --msgbox "$1 new mails @ $2"
    Or something like that in the script.

     
  • ewigkeit

    ewigkeit - 2014-02-26

    Ah, trojita is a button as an example. That's one thing I didn't get myself. So far so good. I get it now that the script (be.mailed) is the trigger for the notification-button and this is working when I run it in the konsole.

    What I also missed until a few minutes ago was that one has to compile the contents from the foo/be-shell/be.idle.imap folder extra (qmake && make). Than you can run ./be.idle.imap to have that excellent helper doing it's magic. That works excellent with my webmail-account.

    But things go ugly when connecting to my own, little, selfhosted Postfix/Dovecot solution, because the SSL-Certificate is self-signed. So I get a lot of verification errors. Can you put me in the right direction to either patch out the SSL-Verification stuff or make it accept it automatically? The MUAs I'm running are also complaining after configuration, but at least you can teach them to shut up and do their work ;).

     
  • Thomas Luebking

    Thomas Luebking - 2014-02-26

    Ok, I added support for a "IgnoredErrors" key per account with 7468117

    Accepts QSslError enum[1] as comma separated list or "ALL"
    I guess that i don't have to tell you that this is in general a major security risk, so use with greatest care only.

    The code is not tested at all since i don't have a broken server at hand ;-P

    [1] http://qt-project.org/doc/qt-4.8/qsslerror.html#SslError-enum

     
  • ewigkeit

    ewigkeit - 2014-02-27

    Thank you very, very much kind sir. If you ever need someone to test on a broken server, I'm your man ;). By the way - is there an option to donate some dime for your effort? Not for helping me out only, but because I really want to support BE:Shell and its developer :).

     
  • Thomas Luebking

    Thomas Luebking - 2014-02-27

    Thanks for the offer, but I do in general not take any money in this context (price of freedom ;-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.