dbus-monitor shows irrelevant lines
Jaakko Luttinen <[email protected]>
| Newsgroups | gmane.comp.freedesktop.dbus |
|---|---|
| Message-ID | <[email protected]> |
Hi all, ### Background I'm trying to implement a very simple dbus listener. Whenever a particular dbus signal is received, a script/command should be executed. In particular, I'd like my own screenlocker to react to the dbus message from loginctl lock-session. If you have any suggestions, how to implement this, I'd be happy to hear. Maybe my approach is a bad one. ### Implementation I wrote a test script that does ``` $ dbus-monitor --system --profile "interface=org.freedesktop.login1.Session,member=Lock" | > while read -r line > do > echo "Received the following signal:" > echo $line > done ``` This solution was inspired by: https://askubuntu.com/questions/150790/how-do-i-run-a-script-on-a-dbus-signal Now it just shows the signals it receives, but ultimately I would replace that echoing code with my actual screenlocking command. I would then run this command as a script executed by a systemd service, I suppose.. Any better ideas? ### Problem However, when I run this command, it immediately receives three signals: ``` dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "Rejected send message, 1 matched rules; type="method_call", sender=":1.277" (uid=1000 pid=27124 comm="dbus-monitor --system --profile interface=org.free" label="kernel") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping. Received the following signal: #type timestamp serial sender destination path interface member Received the following signal: # in_reply_to Received the following signal: sig 1586080954.876039 2 org.freedesktop.DBus :1.277 /org/freedesktop/DBus org.freedesktop.DBus NameAcquired ``` These signals have nothing to do with the signals I told dbus-monitor to watch. So, why am I receiving them? How can I not receive them? If I would put actual screenlocking code inside that while loop, my screen would have been locked three times when I just start monitoring locking signals - that doesn't make sense. So, how can I make dbus-monitor to only show lines that I'm asking it to show? Or if you have better solutions for the original goal in the first place, I'm eager to hear. Best regards, Jaakko _______________________________________________ dbus mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dbus