[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to cause a process started in .xsessionrc to terminate with x-session termination?





niedz., 21 lis 2021 o 20:16 Greg Wooledge <greg@wooledge.org> napisał(a):
>
> Damn.  I was hoping I could come up with a nice, simple way for a novice
> user to introduce a .xsession file and reap the benefits thereof, without
> having to undergo all of the complexity of writing a full-blown .xsession
> file.
>
> Apparently this is not possible.  Debian does not provide a single entry
> point which a .xsession file can call upon to do all of the things that
> the default system session does when .xsession is absent.  That logic is
> buried inside one of the dotted-in files (not scripts) in
> /etc/X11/Xsession.d/.
>
> So, if you want to be able to kill a process while logging out of
> your X session, apparently you need to create a whole .xsession file.
> Congratulations: you're graduating out of novice mode whether you like
> it or not.
>
> The first thing you'll have to do is figure out how to actually start
> your MATE session.  There'll be some magic starting point that you can
> call.  I have no idea what it is.  Debian is probably just using a
> symlink from /usr/bin/x-session-manager or something, so if you can't
> find it on Google or from your own knowledge of MATE, maybe you could
> start with that.
>
> Since you want the process-killing to be done after you terminate your
> interactive session, you need to *not* use "exec" when you execute the
> MATE session.  That way, the shell will still be there to carry on with
> the commands after MATE, one of which will kill the unison process.
>
> In the interests of simplicity, I'd also advise getting rid of the
> .xsessionrc file.  You might as well put everything in one file, instead
> of two files.  It'll be a lot easier to track things down in the future
> when you need to make a change, if they're all in one file.
>
> Putting the unison invocation and the unison kill both in the same file
> also means you can kill it *properly*, by keeping its PID, instead of
> using pkill.
>
> So then, it would look something like this:
>
> your unison thing &
> unisonPID=$!
> other things you want to run
> magic MATE start command
> kill "$unisonPID"
>
> Expect to need to tweak it a few times.  And good luck.

I see, that the real final executor is in the very-last file in the whole sequence:
/etc/X11/Xsession.d/99x11-common_start:

exec $STARTUP

and STARTUP is set, according to file existence, to one of the
        x-session-manager
        x-window-manager
        x-terminal-emulator
but preferably to: ~/.xsession if it exists

So it seems I need to run one of these three standard executables in my .xsession and surround it with my process execution and termination by PID.

Thanks again!





Reply to: