I am working on a script that will detect if and when a Gnome session is "locked" by a user in order to kick that user and prevent people locking screens in a public use lab. However, it seems the only way to do this is to launch a dbus-monitor as follows:
dbus-monitor --session \ "type=signal,interface=org.gnome.ScreenSaver"
Unfortunately I can't get this to work as root, no matter how many things I try. I have tried the following:
1
eval `dbus-launch`
dbus-monitor --session ...
This fails to launch with the same error
2
export $(dbus-launch)
dbus-monitor --session ...
This launches but doesn't successfully monitor the messages.
3
eval `dbus-launch`
export DBUS_SESSION_BUS_ADDRESS
dbus-monitor --session ...
This launches but doesn't monitor the messages
The exact error when I do get the X11 session error is as follows:
Failed to open connection to session message bus: dbus-launch failed to autolaunch D-Bus session: Fd 4 did not have the close-on-exec flag set! Setting the flag.
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified
Autolaunch error: X11 initialization failed.
So simply, I need to be able to monitor the session org.gnome.ScreenSaver dbus messages remotely (ideally as root, since setting up a new user can be a pain) and can't figure out how to do that. It should also be added that if I'm logged in as a user I can run the dbus-monitor command by itself without any problems (it logs as expected).
More info because it can't hurt.
Kernel: RHEL5
2.6.18-406.el5
DBUS Version:
D-Bus Message Bus Launcher 1.1.2
GNOME Version:
2.16.0