How to unlock screen from script in KDE Plasma 5?

I use pam_usb and want to lock/unlock computer when USB stick is removed/inserted. For locking I use qdbus org.freedesktop.ScreenSaver /ScreenSaver Lock and it works perfectly. For unlocking I've tried a series of commands I've found (most of them are aggregated here), but they don't work. Specifically, if we exclude those with KDE 4 syntax, they fall into 2 categories: those using qdbus (relevant path here, several variations exists) /MainApplication quit which hang my Xorg completely, and those using killall against screenlocker process, but the process just restarts instantly after that!

So, my question is: how to unlock KDE5 screen locked with its standard locker programmatically?


Solution 1:

Not really my answer, but it might be useful to someone else too.
It comes from https://forum.kde.org/viewtopic.php?f=289&t=130691#p350000 and it works on latest archlinux with kde 5.7

loginctl lock-session
loginctl unlock-session