t_fischer: (computer)
[personal profile] t_fischer

Recently, I stumbled upon a blog posting on how to make Psi logout on suspend in KDE. Although I am not using suspend myself for security reason, using D-Bus to control applications has its charm. In this posting, I will present some more use cases for D-Bus and Psi.

To explore which (running) applications offer a D-Bus interface and can be remote controlled, I recommend qdbusviewer (part of QtGui). In the tab "Session Bus", search for "org.psi-im.Psi". On the right side, all functions Psi offers appear. Browse to "Main", "org.psi_im.Psi.Main". Here you see methods such as "openURI" or "sleep". Double-clicking on one of the methods calls those them. If the methods requires parameters, a window pops up where you have to enter values. What values to enter may not be obvious and requires reading the applications documentation and source code (or searching on the Internet for someone who already figured it out).

For our purpose, changing the online status and the status message is a good example, which can be achieved by calling "setStatus". The nice thing about D-Bus is that it is supported by many applications, even Gnome and a Windows port exists as well. You can call D-Bus methods using command line tools like dbus-send. For example, to set your online status to away and set the message to "Gone ...", simply run:

dbus-send --type=method_call --dest=org.psi-im.Psi /Main org.psi_im.Psi.Main.setStatus string:"away" string:"Gone ..."

Other possible values for your online status include "online", "offline", and "dnd".

The next step is to call dbus-send on special events. The original posting as referred to above calls this method to make Psi sleep on suspend, but we can do more. For example, you can set Psi online and offline when you login and logout. To achieve this, open KDE's System Settings, go to "Application and System Notifications" and search for "KDE Workspace" in the "Event source" drop-down list. Select the event "Logout" and check "Run command" at the bottom of the dialog. Now enter a dbus-send command as shown above, but use offline as the first string's value and nothing as the second string's parameter. You can do the same for Login events (using online and a more useful message).

Next, you may want to switch to away when you lock your screen or the screen saver activates automatically. Where you selected "KDE Workspace", select "Screen Saver" now. The events you are looking for are "Screen saver started" and "Screen saver exited". For the screen saver start event, you may want to run a command like this:

dbus-send --type=method_call --dest=org.psi-im.Psi /Main org.psi_im.Psi.Main.setStatus string:"away" string:"Saving screens"

For the screen saver exit event, switch back to online.

To avoid any confusion, disable automatic logins (per account) and auto-away features (global option) in Psi, as they became unnecessary when using KDE's notifications.


t_fischer: (Default)
Thomas Fischer

September 2017

34567 89

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags