You are not logged in.

#1 2019-01-29 21:18:05

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,000

Autologin and startx without a display manager.

Done this a bunch of ways and times, not always with the greatest of success but this is a method I'm using and like. It's really just information snagged here and there online but is tested. The OS in particular is a Debian 9.7 install. Should apply to Bunsenlabs and tons of others.

Using systemd to autologin,

Create a directory named getty@tty1.service.d and a file in it called override.conf in the following location.

/etc/systemd/system/getty@tty1.service.d/override.conf

Edit that override.conf file to contain the following.

[Service]
Type=simple
ExecStart=
ExecStart=-/sbin/agetty --autologin yourusername --noclear %I 38400 linux

Obviously someone puts their username or name of the user they wish to autologin to the operating system, where it says yourusername above. Save the file and whamo, someone now has autologin in tty1 when they boot-up. Which can be useful and convenient itself.

Next up, going to use startx/xinit and an .xinitrc file in the users /home to set what gets used for that session.

To autostartx we edit the .profile file in your users /home and add the following to the bottom of it.

#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
. startx
logout
fi

At this point, when someone boots up, the user they selected is logged in and the above executes startx, now all we need is an .xinitrc file in the users /home to decide which DE/WM should be launched for that session.

Here's my .xinitrc file contents as an example. So if someone doesn't have an .xinitrc file, make one, add the following to it and make it executable with "chmod +x .xinitrc" in terminal or however you go about doing such.

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi

# exec enlightenment_start
# exec i3
# exec mate-session
# exec xmonad
# exec startlxqt
# exec startlxde
# exec awesome
# exec bspwm
# exec gnome-session
# exec gnome-session --session=gnome-classic
# exec startkde
# exec startxfce4
# exec startfluxbox
exec openbox-session
# exec cinnamon-session
# exec pekwm
# exec catwm
# exec dwm
# exec startede
# exec icewm-session
# exec jwm
# exec monsterwm
# exec notion
# exec startdde # deepin-session

To select what I'm going to use, I just uncomment one of them, removing the # in front of it. Only one should be left uncommented at a time and switching is just a matter of editing this file. Above I've got openbox-session uncommented and am using openbox.

There are tons of ways people do this, no shortage of methods but this one works well for me and hopefully somebody gets good use of the info.

Vll! smile

Last edited by BLizgreat! (2019-01-29 21:23:43)

Offline

#2 2019-01-30 07:25:58

ohnonot
...again
Registered: 2015-09-29
Posts: 3,764
Website

Re: Autologin and startx without a display manager.

could you please use CODE tags for code?

btw, is the dot before startx there on purpose? i.e. source a script called startx?

#Startx Automatically
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
 . startx
 logout
fi

anyhow:

BLizgreat! wrote:

Next up, going to use startx/xinit and an .xinitrc file in the users /home to set what gets used for that session.

this is how it works on my archlinux, but ex-user H.o.a.S. once convinced me that on debian, things break when you do it like this.

Last edited by ohnonot (2019-01-30 07:26:18)

Offline

#3 2019-01-30 07:49:05

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,350
Website

Re: Autologin and startx without a display manager.

ohnonot wrote:

Well, if not break, as least fail to work as expected without a lot more config from the user.

On Debian, even without a DM, startx already calls up a lot of startup stuff (dbus, etc etc) that packages drop in
/etc/X11/Xsession.d/ (have a look)

If you make a custom .xinitrc, all that gets ignored and you have to set it up yourself.

HoaS also linked to my old thread on this: https://forums.bunsenlabs.org/viewtopic.php?id=3774

The simple way:
Run plain 'startx' with no arguments. Don't use an ~/.xinitrc file. If you want to specify a particular window manager, or some startup script, put it in ~/.xsession. If you want to specify locales/languages or environment variables (like PATH) put them in ~/.xsessionrc, or put them in ~/.profile if you want them to apply for tty sessions too.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#4 2019-01-30 14:40:25

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Autologin and startx without a display manager.

I think you would be better off having a login manager in this case, just create .desktop files in /usr/share/xsessions?

I mean you have to go in and change config settings to get to the wm etc but all you have to do from the login manager like say lightdm is to select session from a dropdown box?

I use startx myself as i have no need for a display manager but i only have a few window managers i use, namely dwm,cwm,openbox but im leaning towards using dwm full time now so cwm,openbox may become redundant.

Edit: and surely having that many wm's and de's on one machine would have to have some sort of clash with eachother or some form of incompatibility ??

Last edited by S7.L (2019-01-30 14:48:57)

Offline

#5 2019-01-31 06:50:19

ohnonot
...again
Registered: 2015-09-29
Posts: 3,764
Website

Re: Autologin and startx without a display manager.

S7.L wrote:

I think you would be better off having a login manager in this case, just create .desktop files in /usr/share/xsessions?

to each what they like, but to me, it just adds a useless layer to my gui stack.

I mean you have to go in and change config settings to get to the wm etc but all you have to do from the login manager like say lightdm is to select session from a dropdown box?

installing things the distro was not shipped with almost always requires additional setup, whether you use a display manager or not.
_____________________

i think display managers make sense when you have a multiuser system, maybe even for a laptop that needs to be locked properly when left unattended.
for my case it's useless.

Offline

#6 2019-01-31 11:22:21

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Autologin and startx without a display manager.

^ true that but sometimes that extra layer makes life easier, like this little zenity script i found. Lightdm is good if you want to use pam-usb and things like this though or can you use them without a login manager? i haven't checked.

#! /bin/bash

PROGRAM=$(zenity --width=300\
           --height=300\
           --list\
           --title "SelectWm"\
            --text "Select Window manager"\
            --column ""\
            "openbox"\
            "pekwm"\
            "fusion-icon"\
            "ion3"\
            "ratpoison"\
            "wmii"\
            "fvwm-crystal"\
            "startxfce4"\
            "awesome"\
                )


case $PROGRAM in 
    (openbox) 
         exec   openbox-session;;
    (pekwm) 
         exec   pekwm;;
    (fusion-icon) 
         exec   fusion-icon;;
    (ion3) 
         exec   ion3;;
    (ratpoison) 
         exec   ratpoison;;
    (wmii) 
         exec   wmii;;
    (fvwm-crystal) 
         exec   fvwm-crystal;;
    (startxfce4) 
         exec   startxfce4;;
    (awesome) 
         exec   awesome ;;
esac

Ive not tested this in .xinitrc but it runs fine from the shell. I might have to test it out with a few wm's i have.

Last edited by S7.L (2019-01-31 11:23:14)

Offline

#7 2019-01-31 16:14:09

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,000

Re: Autologin and startx without a display manager.

Haven't seen any issues with this. Though am dang sure not the final word on the workings of X. Also thought my use of quote tags made the finished babble, very pleasing to the eye. tongue Thanks for the feedback guys. Really do need to do some digging into any wider implications of .xinitrc. Wanted to dork around with it, not to the point that it could have a negative effect on other nixers systems.

Last edited by BLizgreat! (2019-01-31 16:37:17)

Offline

#8 2019-02-01 12:48:11

DeepDayze
Member
From: In Linux Land
Registered: 2017-05-28
Posts: 681

Re: Autologin and startx without a display manager.

If you want to play with this why not set up a test user so you don’t break things with your regular user account?


Real Men Use Linux

Offline

#9 2019-02-01 15:36:08

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,000

Re: Autologin and startx without a display manager.

Not afraid of breakage, am about misleading other nixers though. This is working fine for simple things like openbox/Fluxbox but hadn't exhaustively tested outside that.

With enough people expressing concerns, probably best to delete this.

Offline

#10 2019-02-02 02:21:51

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 5,350
Website

Re: Autologin and startx without a display manager.

Not delete surely? It's an interesting topic that comes up often.


John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#11 2019-02-02 03:13:33

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 730

Re: Autologin and startx without a display manager.

Personally, and being both lazy & perfectly satisfied wit openbox/Bunsen, if I wanted to ditch lightdm.. & didn't wan to simply login at a tty & then "startx" I'd look seriously at the "nodm" display manager;.


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

#12 2019-02-02 08:11:09

ohnonot
...again
Registered: 2015-09-29
Posts: 3,764
Website

Re: Autologin and startx without a display manager.

i never quite understand why people even use nodm:

  • the automatic log in to tty as outlined in post #1 is possible on all systems i'm aware of

  • from there it's just a small addition to your shell login script (~/.profile, ~/.bash_profile etc.):

    [[ $XDG_VTNR -eq 1 ]] && startx

    (that's to start X only on tty1, not even strictly necessary)

it's an honest question; nodm has been around for more than a decade, surely there must be a reason?

Last edited by ohnonot (2019-02-02 08:12:05)

Offline

#13 2019-02-02 09:44:12

S7.L
Member
Registered: 2018-09-16
Posts: 338

Re: Autologin and startx without a display manager.

^ If going by the archwiki it is meant for smartphones?

Ive never used it but it looks like it is an easy way to autologin and startx simultaneously ?

https://wiki.archlinux.org/index.php/Nodm

Last edited by S7.L (2019-02-02 09:44:41)

Offline

#14 2019-02-02 17:06:39

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,000

Re: Autologin and startx without a display manager.

Hey no problem totally good with leaving it too. Just don't want to put up info that could have an adverse effect on other nixers.

Works well enough for me but wouldn't have much trouble finding a fix, if were to run into issues. Have a thread about nodm somewhere in the forum. Had it working on desktop but if remember ended up not liking it. Hadn't invested much time or effort into it either though.

Last edited by BLizgreat! (2019-02-02 17:08:22)

Offline

#15 2019-02-03 11:35:01

ohnonot
...again
Registered: 2015-09-29
Posts: 3,764
Website

Re: Autologin and startx without a display manager.

BLizgreat! wrote:

Works well enough for me

and so it does for me, for many years already, without notable problems.

Offline

#16 2019-02-06 22:20:06

BLizgreat!
Resident Babbler - vll!
Registered: 2015-10-03
Posts: 1,000

Re: Autologin and startx without a display manager.

^Thanks. smile

To tell the truth never really thought of a compelling reason to forgo using a good display manager. Other than simply for the sake of it and you can factor.  The system overhead and any added boot time of a DM are trivial anyway. Still kind of like this more raw approach, stripping out unneeded elements while retaining functionality and convenience. If that creates any kind of system compromise. It'd be a fail imo.

Vll! smile

Last edited by BLizgreat! (2019-02-06 22:21:02)

Offline

#17 2019-02-06 22:59:32

Bearded_Blunder
Dodging A Bullet
From: Seat: seat0; vc7
Registered: 2015-09-29
Posts: 730

Re: Autologin and startx without a display manager.

Well, dunno if it's compelling or not, but lightdm starts & runs X as root, without in my test installs X runs as my user. It might be a security consideration I suppose.


Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me

Offline

Board footer

Powered by FluxBB