[xubuntu-users] How to get process to start with GUI login and exit on GUI logout?

Chris Green cl at isbd.net
Tue Feb 1 08:46:50 UTC 2022


On Mon, Jan 31, 2022 at 09:00:45PM -0600, Knute Johnson wrote:
> 
> 
> On 1/31/22 17:17, Chris Green wrote:
> 
> > It's currently being started by a .desktop file in
> > ~/.config/autostart, the standard way created by an entry in 'Session
> > and Startup'.  It's just a bash shell script.
> > 
> > 
> > > You are probably going to have to start it with systemd.
> > > 
> > I don't think that helps does it, systemd doesn't have the ability to
> > start a program when an X session is started, nor can it stop a
> > program when X exits.
> > 
> 
> It's really easy to start a program with systemd once the desktop is up but
> I cannot for the life of me figure out a way to stop one.
> 
> GUI programs stop when you exit the desktop. I've got one idea I'm going to
> try tomorrow and that is wrapping the script in a Java program that opens a
> window.  If it kills the VM it should kill the script running in it as well.
> 
As far as I can tell all of the programs that are children of
xfce4-session and thus exit when the session ends are compiled
executables and thus probably call session management functions to
handle session shutdown.  Most of them in fact have a parameter
"--sm-client-id <id>" which presumably means that the session manager
probably tells them to shut down.

Thus it would seem that a program has to hook into some sort of
session management library function to be able to exit at end of
session.

-- 
Chris Green



More information about the xubuntu-users mailing list