Is there a universal way to identify X session from the inside?

view story

https://bbs.archlinux.org – Hi everyone!I wrote some bash daemons designed to be started by xdg autostart mechanism.The problem is: unlike X clients, bash scripts do not exit on logout from X session or when X is killed.subproblem: script needs to do some housekeeping when exiting.I'm looking for DE/DM-independent way of telling if current user X session still exist, or not. Or a way to catch the end of session.Testing for $DISPLAY is meaninglessTesting for X PID is unreliable (for example, xdm reuses same X process for itself and user sessions)Not every session manager gives its PID to child processes as PPID.env o (HowTos)