You are not logged in.

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

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

Autologin and startx without a display manager.

Ok fellas, am updating this cause have settled on some refinements to it. This is a copy of the tute I've already slapped up on another forum and overall is better in my view. All such stuff is covered in this how-to as well. However it's scattered throughout this thread, so am cleaning it up, putting it all in one place at the top of this sucker. smile Let's get to it ...

Yet another auto-login and start your prefered desktop/windows manager without a display manager running on the OS thread.

Ok another thread in the forum, brought this to mind, (Wizard10000) mentioned that the only display manager which doesn't launch-run X as root is GDM. This is likely to be irrelevant in future, with Wayland and honestly I don't overly care as it is anyway but still on with the thread. smile

1. Using systemd to autologin a user.

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

Here's what you'd add to that override.conf file.

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

That's what it'll do, automatically login the user named, where it says yourusername. Put the desired username there.

2. To automatically startx edit the .profile file in your users /home directory and add this to the bottom.

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

Ok, that will automatically run startx, when your user logs in.

3. Now say you have several DE's/WM's installed. You'll obviously want to be able to pick and switch between them. This is where update-alternatives comes into it.

Enter the following command to pick which will be the default xsession, until it's changed.

sudo update-alternatives --config x-session-manager

Select the one you want to be default and you're good to go. ALMOST. Most DE's etc will be well behaved and will add a selection for themselves to x-session-manager for you. However sometimes I've found that won't be the case however you can add an entry for it yourself. ie: Let's take fluxbox by way of example. I want to add it to the x-session-manager section of update-alternatives, so I can choose it there whenever I want. Here's how ...

sudo update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/bin/fluxbox 40

In the above, I'm installing something to the x-session-manager group of update-alternatives, in this case, fluxbox, /usr/bin/fluxbox is where fluxbox errrr, lives big_smile and I'm giving it a priority of 40 there. Although it doesn't overly matter. Once it's selected it'll launch as default x-session until something else is chosen.

NOTE: Ok another scenario, the above is perfectly fine for a single user system but what about a multi-user one or one on which you want to be able to login more than one username. Easy, peasy, just skip step 1 (or remove the directory/override.conf file. You'll be met with a command-line login to enter the user and password you want to use.

Finally, you likely already have a display manager running. For all this automagic-ness to work, you'll have to change that. Couple options, remove the display manager from your OS, you can always reinstall it later if desired. Another would be to use "sudo systemctl disable lightdm" to disable lightdm and keep it from automatically starting every time the system boots up. If at some point in future you wish, re-enable the sucker with "sudo systemctl enable lightdm" and you may also need to run "sudo dpkg-reconfigure lightdm" too. After which the sucker should be up and running again.

IMPORTANT NOTE: Make sure you have the xinit package installed "dpkg -l |grep xinit" if not yep, install it ! "sudo apt install xinit", just found out the hard way I didn't have the stupid thing on a 32b/Stretch minimal netinstall OS when went to remove lightdm and set this junk up. Kept getting problems until did the above and installed the dang xinit = startx command.

********
Original how-to on this ... It's still interesting in ways.

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-11-13 07:06:20)

Offline

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

ohnonot
...again
Registered: 2015-09-29
Posts: 4,163
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: 6,065
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, 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: 4,163
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,217

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: 761

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,217

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: 6,065
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, 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: 4,163
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,217

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: 4,163
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,217

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

#18 2019-07-04 06:21:12

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

Re: Autologin and startx without a display manager.

Hey folks, hope everybody here is doing well. big_smile

Got to dorking around with this again. Haven't had any issues and the info in this seems fine to me as is but followed the link Ohnonot had provided. In which Hoas mentions using an .xinitrc file could cause issues, whereas also said simply running startx does the same thing using a display manager would.

Of course yours truly was also babbling away in the thread and it reminded me of an approach to this which doesn't require use of an .xinitrc file, namely Debian's update-alternatives.

Someone can remove any .xinitrc file from their users /home and just use the first part of the tute. Choosing whichever DE/WM they want to be launched by setting it in x-session-manager. Any full blown Desktop (and many others) are going to automatically add an entry in x-session-manager. Some however are not as refined and a little finnagling is needed to get them to show up as a choice. Going to use fluxbox by way of example.

It's installed on this OS, however there isn't a choice for it in x-session-manager out-of-box. So let's add it.

I run the following command "sudo update-alternatives --config x-session-manager" and the only option is openbox, no good I want fluxbox to be the default x-session, time to add it.

sudo update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/bin/fluxbox 40

Syntax here goes

update-alternatives: --install needs <link> <name> <path> <priority>

I'm obviously trying to add/install something for x-session-manager here ... fluxbox.

Ok that's about it next time I run the update-alternatives --config/etc command, now fluxbox shows up as an option. So that's all I have to do to set it as default. Run that command and choose fluxbox. Next time I bootup, it's launched as the default x-session until something else is set. Sans .xinitrc file ...

Mostly just being a dork here. This is kinda clunky but related. Haven't posted or been active in the kickbutt BL community (or any community) in awhile, so wanted to post something and say hello fellow nixers. VLL! smile

Offline

#19 2019-07-04 16:47:27

iMBeCil
WAAAT?
From: Edrychwch o'ch cwmpas
Registered: 2015-09-29
Posts: 649

Re: Autologin and startx without a display manager.

Hi blizgraet ... I'm drunk ... it's so called little friday, today.

Can't really see what you have wriiten .. letters are dancing left and right.

Neverthelss, if you are asking ybout starting WM/DE withoud LM (lgi-in mnager), then it is enough to put this:

# start X if we are on tty1, and we just logged in
if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
   startx
fi

in .bashrc. This will ensure a X session is started, as soon as you are logged in in terminal.

Blaaaaaaaaa ... (I know, I will regret it tommorow.)


Postpone all your duties; if you die, you won't have to do them ..

Offline

#20 2019-07-05 04:33:03

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 6,065
Website

Re: Autologin and startx without a display manager.

Hi BLizgreat! good to see you back!

FWIW BunsenLabs Lithium will ship with its own session script, registered with debian-alternatives and set as default for x-session-manager (although users can choose other DEs instead).
Also in LightDM's login menu.


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

Offline

#21 2019-07-05 19:22:10

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

Re: Autologin and startx without a display manager.

Lmao IMBeCil, hope any hang-over turned out really light.

John-san! Nice you guys have always put out polished gnu/nix goodness.

Offline

Board footer

Powered by FluxBB