Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Gnome, what signal on dbus-monitor indicates the user is logging out?

Tags:

gnome

dbus

I want to write a script that runs in the background and detects when a user logs out. I am having trouble finding documentation on dbus-monitor. The best I can do is that I see a flurry of EndSessionQuery, EndSession, and EndSessionResponse but these all come with booleans so they can't fully be trusted (maybe a program says it doesn't want the user to logout?) and on top of that, what if no programs are open? This is too unreliable.

What I want is to listen for a signal that will always happen when the user is logging out. Can someone provide that signal? Currently I am running this command:

dbus-monitor --session \
    "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" | \
        myprog

which catches the ScreenSaver events. But I also want to catch logout. What I wish for is something like:

dbus-monitor --session \
    "type='signal',interface='org.gnome.Session',member='LogoutSuccess'" \
    "type='signal',interface='org.gnome.ScreenSaver',member='ActiveChanged'" | \
        myprog
like image 351
Robert Martin Avatar asked Jan 14 '13 16:01

Robert Martin


2 Answers

Look for the files called org.gnome.SessionManager.* here: http://git.gnome.org/browse/gnome-session/tree/gnome-session

There is a SessionOver signal in the interface org.gnome.SessionManager that may be what you need.

Are you looking for the normal "session is ending, quit yourself or put up a prompt or something" request from the session manager, or a "session is really ending now, bye bye" signal?

like image 179
Federico Mena-Quintero Avatar answered Nov 07 '22 01:11

Federico Mena-Quintero


This is an old thread, but I'm adding some info in case anyone else needs it.

I had the same needs, but ended up implementing a Session Manager DBus client as an easy to use script. It executes a user-defined script on logout. The ready to use application is shared on GitHub.

Gnome EndSession DBus client

like image 24
Pablo Cases Avatar answered Nov 07 '22 03:11

Pablo Cases