The officially official Devuan Forum!

You are not logged in.

#1 2018-05-01 21:51:31

GNUser
Member
Registered: 2017-03-16
Posts: 570  

when X is killed, lightdm restarts it [SOLVED]

I use Ctrl+Alt+Backspace to kill my X session. Please, how do I prevent lightdm from immediately restarting X and showing a graphical login screen when the X session is killed?

When I kill the X session, it is because I want to work in a virtual console without X running.

I perused /etc/lightdm/lightdm.conf and /etc/init.d/lightdm but didn't find anything promising.

Last edited by GNUser (2018-05-02 12:30:05)

Offline

#2 2018-05-01 22:46:05

devuser
Member
Registered: 2018-04-30
Posts: 176  

Re: when X is killed, lightdm restarts it [SOLVED]

Not much experience there but i fear it'll be tricky to archive that. I guess /etc/init.d/lightdm contains some kind of loop that simply restarts X and lightdm when X is being killed. If thats the case the problem would be that script runs as root and has no idea what user was logged in at the moment X got killed so it wouldn't know how to spawn a matching shell.

If you have some way to figure out if a session started by startx was killed or if the user simply logged out i think you could hack something together with a script wrapping around /bin/login but i wouldn't know how to do that in a generic non DE dependant way.

Offline

#3 2018-05-02 09:03:33

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: when X is killed, lightdm restarts it [SOLVED]

Er... that is what lightdm is for. When you have closed down a session, it lets you log in again ;-)

If you want a console <CTRL><ALT><F1> will connect you through to tty1: and you can log in. If/when you want to get back to X you can type <CTRL><ALT><F7> as X runs on tty7:

Is that what you want?

Geoff

Offline

#4 2018-05-02 10:26:34

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

Thank you, Geoff42. Those shortcuts are exactly what I use when I want a console.

I appreciate lightdm presenting a new graphical login screen when I log off. IMHO that is expected behavior.

When I kill X what I would like is, well, for X to be killed in tty7, stay dead (e.g., so that I can install/uninstall X-related packages), and for the system to present me with a non-GUI login or command prompt in tty7.

Lightdm's current (default) behavior "resurrects" X as soon as I kill it, which is annoying.

Last edited by GNUser (2018-05-02 10:46:53)

Offline

#5 2018-05-02 10:38:28

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

Back in my Arch Linux days, I was able to get lightdm to behave itself by creating /etc/systemd/system/lightdm.service.d/norestart.conf with this in it:

[Service]
Restart=no

What would be the Devuan/SysVinit equivalent?

Last edited by GNUser (2018-05-02 10:39:00)

Offline

#6 2018-05-02 11:18:03

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,486  

Re: when X is killed, lightdm restarts it [SOLVED]

/etc/init.d/lightdm start|stop|restart

or

service lightdm start|stop|restart

An alternate solution would be to remove the lightdm symlinks for one runlevel. Easy way: install sysv-rc-conf, run it and remove the check mark from lightdm for runlevel 3. (arrows, space bar and q to quit). Then in a root terminal, just run

init 3

to get to multi-user without graphical environment. 

To restart lightdm:

init 2

Offline

#7 2018-05-02 11:19:15

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

Making progress: If I bind Control+Alt+Delete to this command, it does more or less what I want: sudo chvt 1; sudo service lightdm stop

The problem with this is that when lightdm stops, it leaves behind nothing but a black screen with a blinking cursor in tty7, thus rendering tty7 unusable. Doesn't lightdm know how to stop gracefully (e.g., to a command prompt or CLI login prompt)?

Last edited by GNUser (2018-05-02 11:21:07)

Offline

#8 2018-05-02 11:33:13

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

fsmithred, the runlevel approach is pretty clever.

Normally when I want to remove a symlink for a runlevel, I just go with the absolute easiest way and prepend the link's name with an underscore.

Here's what I tried:

$ sudo mv /etc/rc3.d/{,_}S04lightdm
$ sudo init 3

But the above is not working: Switching runlevels has no discernible effect--I still find myself in my MATE session with both X and lightdm still running. I can confirm that the change in runlevel did occur:

bruno@thinkpad:~$ runlevel
2 3

Any ideas?

Last edited by GNUser (2018-05-02 11:49:15)

Offline

#9 2018-05-02 11:44:25

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

fsmithred, here is a variation on your idea that is getting me closer to what I want:

In /etc/init.d/lightdm, change this

# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6

To this

# Default-Start:     2 4 5
# Default-Stop:      0 1 3 6

Then run these commands:

sudo update-rc.d lightdm remove
sudo update-rc.d lightdm defaults

Now switching from runlevel 2 to 3 with sudo init 3 does stop lightdm and X. The only problem with this is that, as in my approach in #7, lightdm quits to a black screen with blinking cursor and not to a prompt.

Isn't there any way for tty7 to be usable after lightdm stops?

Last edited by GNUser (2018-05-02 11:51:48)

Offline

#10 2018-05-02 12:05:25

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: when X is killed, lightdm restarts it [SOLVED]

I suppose you'll then need to arrange for running /sbin/getty 38400 tty7 in runlevel 3. For example, you add a line for this to /etc/inittab, to let init manage it:. E.g., the following as a line after the tty6 line might do the job:

7:3:respawn:/sbin/getty 38400 tty7

Offline

#11 2018-05-02 12:26:12

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

BEAUTIFUL, ralph.ronnquist! Yes, that does it.

So to summarize:
1. Do the steps in post #9
2. Add the line to /etc/inittab as shown in post #10
3. Bind Control+Alt+Backspace to run the command sudo init 3 (e.g., via xbindkeys)
4. Disable* the system's Control+Alt+Backspace keybinding to kill X server (if your system has that binding)

Now the behavior is exactly what one would expect: Logging out causes LightDM to show a graphical login screen, while Control+Alt+Backspace kills X and lightdm, and the user gets a CLI login prompt in tty7. To return to a graphical session in tty7, user types sudo init 2 (if xinit package is installed, startx also works).

* I don't know a CLI or DE-agnostic way to do this. In MATE: System > Preferences > Keyboard > Layouts > Options > Key sequence to kill the X server > uncheck the Control+Alt+Backspace box

Last edited by GNUser (2018-05-02 12:34:02)

Offline

#12 2018-05-02 12:51:36

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

ralph.ronnquist: The above works, but I was wondering if we could make it a lot simpler.

Maybe we could simply write a one-liner that does everything we need? I was thinking something like this, but it doesn't work:

sudo service lightdm stop; sudo /sbin/getty 38400 tty7

No luck with this either:

sudo chvt 1; sudo service lightdm stop; sudo /sbin/getty 38400 tty7; sudo chvt 7

Any ideas how to tweak the above so that it works?

Offline

#13 2018-05-02 13:19:31

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: when X is killed, lightdm restarts it [SOLVED]

It might not work well given that the C-A-Del handler command processing is terminated together with lightdm. You will almost certainly need to spawn a separate script for the actions, and perhaps that it also needs to escape the user cgroups, as it might otherwise be killed together with lightdm anyhow. Apart from that, it's easy smile

Though, the return to X might then also need attention; or does X start happily on tty7 while it's in use by a running getty?

I'd rather suggest that utilizing runlevels (and init) is the "simple" approach.

EDIT: or, it might be possible to shift to, say, tty1 instead, and then not start getty for tty7 at all. The "simpler" line would then be:

sudo chvt 1 ; sudo lightdm stop

I.e., first shift to tty1, then kill lightdm (and the C-A-Del handling). The return to X would be the command

$ sudo lightdm start

If that works, I would call it simpler smile

Offline

#14 2018-05-02 18:56:04

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: when X is killed, lightdm restarts it [SOLVED]

Yes, it works. Wow, that is much simpler. Thank you for that!

Last edited by GNUser (2018-11-08 15:57:43)

Offline

Board footer