How do I prevent xdm from restarting X once I quit the window manager?

I would like to be able to quit the window manager and exit X, but xdm restarts it. What do I have to modify so that this does not happen?
 
Don't use XDM in the first place.

Instead perhaps log in as a user and immediately run startx from your profile scripts if tty returns "/dev/tty0"

If you don't want to login, perhaps you could also run startx from /etc/rc.local (i.e using su -l <username> -c startx)

If you really need XDM for some reason, then yes as roccobaroccoSC mentioned, you could execute sudo service xdm stop after the commands in your .xsession file (after configuring sudo to be able to run that command passwordless)
 
Thanks for answering. When I do sudo service xdm stop it doesn't work. It says xdm does not exist in /etc/rc.d or the local startup directories (/usr/local/etc/rc.d), or is not executable. Is there another way?

I'm used to xdm since I also use OpenBSD and startx is disabled there for security reasons. I may change to it though.
 
Then you probably use another display manager. I thought XDM because you wrote so.
Try:
Bash:
service sddm stop

service gdm stop

service slim stop
 
sudo pkill -9 xdm
That will kill xdm(8), stone dead, but not it's child, Xorg(1) (or whatever you use to run your display).

init(8) has a mission to constantly respawn xdm(8), in the manner of getty(8).

Killing xdm(8) (and all its children) more than once may seen to work, because init(8) will eventually refuse to respawn xdm(8) too rapidly. But it will come back after the next reboot.

To "stop the service" edit /etc/ttys, as suggested above. To make init(8) take notice of the change:
Code:
sudo init q
 
I might suggest instead launching xdm using rc.local (and disable it from /etc/ttys) and then it should not get restarted if you pkill -9 it.

However then you might as well just use startx instead.
 
Why don't you start X from crontab :
@reboot startx
And then when you log out of X session, you will be back to the terminal login prompt.
 
How are you starting XDM?

This is what I did: pkg install xorg xdm, and as the handbook says I modified /etc/ttys with ttyv8 "/usr/local/bin/xdm -nodaemon" xterm on secure.

Then I created a .xsession file with:
Code:
xterm &
dwm

When I boot, the xdm login appears and once I'm authenticated the window manager starts. However, if I close the window manager, the xdm login appears again instead of the system console.
 
grep xdm /etc/ttys may provide the clue. If it's "on" change it to "off".

Isn't the "on" needed if I want xdm to start automatically when I boot? I would like to keep this behavior, but also be able to exit X to the system console just by closing the wm.
 
Then you probably use another display manager. I thought XDM because you wrote so.
Try:
Bash:
service sddm stop

service gdm stop

service slim stop

I only installed XDM and it is the one I'm using. Do you know why sudo service xdm stop doesn't work? Thank you.

Edit: Nevermind, I've just read kpedersen answer.
 
On some setups, both the rc.local and crontab methods will actually leave your X11 session unable to use the keyboard. This is because if they start X before the command prompt login starts up in the background, the login will steal the keyboard input. Something like this is more robust.


Basically it consists of getting the console login to automatically log a user in, and then the profile script will start X.
 
Isn't the "on" needed if I want xdm to start automatically when I boot? I would like to keep this behavior, but also be able to exit X to the system console just by closing the wm.
They are mutually incompatible goals.

If you start X11 via init(8) with an entry in /etc/ttys, you have to edit /etc/ttys (and init q) to stop it. Otherwise it will re-spawn constantly.

If you start X11 via startx(1), it has to be done manually. But you will get the console back when it exits.

Are you aware that you can leave X11 running, and switch to a virtual terminal (of the type you get when xdm(8) exits) using the Ctrl-Alt-F1 through Ctrl-Alt-F7 key combinations (7 different virtual terminals are available)?
 
Are you aware that you can leave X11 running, and switch to a virtual terminal (of the type you get when xdm(8) exits) using the Ctrl-Alt-F1 through Ctrl-Alt-F7 key combinations (7 different virtual terminals are available)?
That's how I do it. Seems to be the simplest and most direct way to operate.
 
Back
Top