I would like to execute a program every time I unlock the screen of phosh. Ideally it should work on the phone the same way as on the desktop. I am currently on mobian but I will use this mechanism later on my L5, too.
I don’t have experience with dbus, but I tried find out if there is some message indicating the unlock that could be used for triggering a program start. I logged the buses to a file, locked the screen and unlocked it. In the session bus there were no results for either log
nor lock
. On the system bus there where no results for lock
but here is what I found for log
:
mobian@mobian:~/development/projects/execOnUnlock$ grep log dbus_system_lock.txt
signal time=1624024579.212102 sender=:1.2 -> destination=(null destination) serial=373 path=/org/freedesktop/login1/session/_32; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Session”
signal time=1624024579.214602 sender=:1.2 -> destination=(null destination) serial=374 path=/org/freedesktop/login1/seat/seat0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Seat”
signal time=1624024579.216155 sender=:1.2 -> destination=(null destination) serial=375 path=/org/freedesktop/login1/user/_1000; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.User”
signal time=1624024579.219100 sender=:1.2 -> destination=(null destination) serial=376 path=/org/freedesktop/login1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Manager”
signal time=1624024580.776667 sender=:1.2 -> destination=(null destination) serial=378 path=/org/freedesktop/login1/session/_32; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Session”
signal time=1624024580.781937 sender=:1.2 -> destination=(null destination) serial=379 path=/org/freedesktop/login1/seat/seat0; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Seat”
signal time=1624024580.785519 sender=:1.2 -> destination=(null destination) serial=380 path=/org/freedesktop/login1/user/_1000; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.User”
signal time=1624024580.793299 sender=:1.2 -> destination=(null destination) serial=381 path=/org/freedesktop/login1; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string “org.freedesktop.login1.Manager”
To be honest I don’t know what to do with that. The sequence of events occurs twice. Maybe the first sequence is the lock and the second is the unlock. How can I get more details of these messages to distinguish them?
Or should I take another path? I am a newbie to systemd but I can imagine that is could be useful, too.
Depending on what program I want to start it actually might already be running. In that case it should be brought to the foreground instead of starting another instance. Some programs may behave like that out of the box. But this is only step two and i should be possible to start a small launcher program which takes care of this logic and eventually starts the app I want to pop up.