Auto-boot Openbox via ~/.xinitrc without putting in your username/password startx

I found some info which is (apart from the systemd stuff) very much like the way I was doing it over a decade ago on Arch. Perhaps someone else here will find it useful (or at least interesting)

So here it is a copy of my note that I made for myself:

To avoid the display manager, execute:

 sudo systemctl set-default 

This will boot system in console mode instead of graphical mode.

Start X automatically when logging into tty1 by adding the following (from Gentoo wiki) to your ~/.bash_profile file:

 if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx; fi

To auto-login via console create a getty override file with

 sudo systemctl edit getty@tty1 

and add following lines in it:

 ExecStart=-/usr/sbin/agetty --autologin username --noclear %I $TERM

where username is your login name.

Then do:

 sudo systemctl enable getty@tty1.

& you should be able to boot into your WM/DE via the content of your ~/.xinitrc

My ~/.xinitrc follows:

#### "#!/bin/sh"   DON'T  USE THIS LINE
# DO be sure to make the file executable though.

# ~/.xinitrc
# This file is sourced when running startx &
# other programs which call xinit.
# As in all Bash/sh scripts.
# Lines starting with # are comments.

# Set background to your favorite pic
#xsetbg -fullscreen /path/to/backgound.png &

# ALWAYS put an '&' at the end of any command 
# except the last one where you call your WM or DE.

# Start an XTerm 
/usr/bin/X11/xterm &

# You can start other applications from here,
# it is what we used to use back in the old days before
# ~/.config/autostart & /etc/xdg/autostart 

# Start the system's window manager
exec openbox-session

That’s it, it works a treat for me, & it really isn’t very hard to do. Getting the info’ is the time consuming part. :wink:

1 Like

Nice info @handy ! Thanks!

Nevertheless, this looks like a proof-of-concept case, or a very limited system (single user).
I wonder what happens if you choose to logout openbox, or kill Xserver. Does it stay on TTY, at the standard login prompt, or loops to re-login again?

Hi @petsam, yes it loops straight back to Openbox (in my case).

When I’ve needed I just use Ctrl + Alt + F2 & login there to use the Terminal.

For my secure, single user situation it works really well so I’ll stick with it.

I edited the ~/.xinitrc you really don’t want to have #!/bin/sh in it. :slight_smile:

1 Like