While playing around with qdbusviewer I discovered that Psi has two D-Bus methods related to power management: org.psi_im.Psi.Main.sleep e org.psi_im.Psi.Main.wake.
Since I’m envying all those friends who go offline with the status: “Computer went to sleep” I wanted to find a way to make to automatically call the sleep method.
I remember that when I suspend my laptop I see the a message from PowerDevil using standard KNotify notifications. KNotify supports executing a command for a specific notification. So I can just call the D-Bus method from there, using dbus-send:
dbus-send --type=method_call --dest=org.psi-im.Psi /Main org.psi_im.Psi.Main.sleep

This isn’t the best way, it’s just a working hack. Theoretically NetworkManager could disconnect from the network before Psi is disconnected, leaving the connection opened. Or the operating system itself may not have enough time to close the TCP connection. It never happened in my few tests though.
Hmm, interesting… Tried that, was not working. Then I tried to put a simple touch command into the Run Command and nothing happened. Do you have any idea why my command is not being started?
Hi jirik,
check in KDE System Settings -> Advanced -> Power Management -> General Settings -> Settings and profile| that “Enable Notifications” is well.. enabled.
Everything checked… Both Enable notifications and Enable warning notifications, also Run command in Performing a suspension job.
Did the suspend to ram again with some other arbitrary command and it is working now; strange.
Thanks
So is it now working or not? if not, does the command alone work?
Note that you need the latest stable version of Psi.