Linux: KDM, startx & the X session

1

I'm using startx in my .bashrc file to start X when I login at tty1 instead of using a display manager like KDM (I'm using KDE 4.3.4). The actual code in my .bashrc:

if [ -z "$DISPLAY" ] && [ "`tty`" = /dev/tty1 ]
then
    startx
    logout
fi

Now the problem is since KDM is not running I'm not able to use the shut down button from the KDE menu (because it needs root privileges to do so) and some other features are gone as well.

Is there a way to start KDM when I run startx in my .bashrc, like just running KDM in the background? The point is that I want no login display, so I'm sure there must be a way to just start KDM silently.

watain

Posted 2009-12-29T13:19:00.727

Reputation: 611

Answers

1

Putting startx in .bashrc is a bad idea. It will prevent you from being able to log in normally to a console. Unless you have a really, really good reason to do so (and I suspect that you, like pretty much everyone else, do not), use a display manager instead.

Ignacio Vazquez-Abrams

Posted 2009-12-29T13:19:00.727

Reputation: 100 516

Exactly. Or do the extra seven keystrokes and run startx the normal way after you log in. – Justin Smith – 2010-04-07T02:31:59.327

0

It is not really clear what you want to achieve, but like Ignacio wrote putting startx into your .bashrc is a really bad idea. If your problem were only that you cannot call shutdown -h from within that session, CTRLALTdel is usually mapped to shutdown -r now in /etc/inittab. You can change it to shutdown -h now in there as well.

If your problem is only that you really, really badly want to have X running on tty1, you can of course start kdm on tty1. Then you would also only have to give your login once (was that the issue?). To do that you need to modify a few files.

  • /etc/inittab:

    Remove/comment the line that spawns the getty on tty1. It looks something like

    ## c1:12345:respawn:/sbin/agetty 38400 tty1 linux
    
  • /etc/conf.d/xdm

    Tell the xdm scripts that they are working on tty1; change the entry in there to

    CHECKVT=1
    

To have X start automatically you of course need it in your default runlevel (added via rc-update add xdm).

Benjamin Bannier

Posted 2009-12-29T13:19:00.727

Reputation: 13 999

Using startx in my .bashrc ain't that bad because I use if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then startx; logout; fi (sorry, I guess I wasn't precise enough there). Your idea with starting kdm on tty1 might look like a acceptable solution. The main reason why I want the text login prompt, is that this way I'd be able to login as root as well, dropping into a shell f.e. for any kind of maintenance. And that's why I start X on tty1 :). – watain – 2010-05-19T18:54:05.330

@watain: for the scenary you mention there are 6 tty's available. Just for reference: Use CTRL-ALT F1..F6 to switch. – Benjamin Bannier – 2010-05-19T22:38:41.077

I'm aware of that, but that's not the point. I simply want to be able to use the text login at tty1 with my user to start X and on all other ttys to get the console after login. – watain – 2010-05-20T17:30:08.197

0

you can set kdm to auto-login, so you'll see no login form displayed. would it help? if it does help, you need to run systemsettings as root (alt+f2 => kdesu systemsettings) then in "login manager" under the "advanced tab" choose "enable auto login" in "convenience" tab.

Capi Etheriel

Posted 2009-12-29T13:19:00.727

Reputation: 668

can you run 'sudo' on .bashrc? it should help you with the permissions issue. auto-login would do everything else once you start the KDM service (usually in /etc/init.d/kdm). – Capi Etheriel – 2010-03-21T15:15:18.133

The problem is that I still want my login prompt at tty1. If I start KDM using a auto-login I won't be prompted for a password at all (as far as I know?). What I want is to login via tty1 and then start X and run KDM in the background. – watain – 2009-12-29T13:50:13.980