You are not logged in.

#1 2012-08-16 12:18:04

Azuric
Member
Registered: 2012-08-16
Posts: 5

[Solved] Choosing to autologin or not by pressing a key during boot

I like to have SLIM set on autologin, but once in a while I want to go straight to a different desktop environment.  I was wondering if there was a way to bypass the autologin, like the way you can get GRUB to show up by holding the shift key.

From the documentation, it seems like SLIM doesn't have this feature, am I right?

Might there be a way for me to put a daemon in rc.conf that watches for a held key and then swaps in a different slim.conf with autologin disabled?

Or even easier, is there another lightweight login manager that has this feature? (Although I really would like to keep SLIM! It's so elegant!)

p.s. my first post here so please tell me if I've broken etiquette! :-)

Last edited by Azuric (2012-08-20 16:44:39)


Now a word about beagles: never look a beagle directly in the eye.

Offline

#2 2012-08-16 14:22:14

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,517
Website

Re: [Solved] Choosing to autologin or not by pressing a key during boot

There are many display managers, but if you normally use autologin, why have a display manager at all?  That just spawns a process and shuts it down doing nothing but slowing down startup times.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#3 2012-08-16 14:37:01

zero_one
Member
Registered: 2010-07-07
Posts: 104

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Just use the default user option. And use the wiki method for switching multiple WM/DE's by pressing f1, or nix slim and just script a start(wm/de). Personally I would never use auto-login or default user options.

Offline

#4 2012-08-17 02:12:31

Azuric
Member
Registered: 2012-08-16
Posts: 5

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Trilby wrote:

if you normally use autologin, why have a display manager at all?  That just spawns a process and shuts it down doing nothing but slowing down startup times.

My understanding is that without a DM set on autologin, I would have to type my user name and password (which I don't feel a need to do on a home computer), and that would slow down startup time even more.

zero_one wrote:

Just use the default user option. And use the wiki method for switching multiple WM/DE's by pressing f1, or nix slim and just script a start(wm/de).

I am using default user and f1 to switch between WM's.

The problem is that 90% of the time I want to boot straight into Fluxbox, without having to loose time login in or seeing the DM. The other 10% of the time, I want to boot to xmonad.  Would there be a way to get a DM (or maybe a script, as you suggest) to send me straight into fluxbox by default, but to appear only if I hold down a given key during boot-up?

Maybe I'm asking too much, but that's how GRUB works, so I thought there might be a way. Could I do this by writing a script and running it as a daemon in rc.conf? Is there a way to tell a bash script to check if a key is being held down?

I found this [https://gist.github.com/3265170] script, but it's for apple, and I think it's written in C, which I know nothing about.

Any tips?


Now a word about beagles: never look a beagle directly in the eye.

Offline

#5 2012-08-17 02:31:57

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,517
Website

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Azuric wrote:

My understanding is that without a DM set on autologin, I would have to type my user name and password

Nope.  You can set autologin to tty1 in inittab.  You can also have your bashrc call startx or xinit if it is logged into tty1.

This could easily be scripted to check for a keypress to login to some other WM, or not login to X at all.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#6 2012-08-17 07:53:15

Azuric
Member
Registered: 2012-08-16
Posts: 5

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Thanks Trilby and zero_one, that'll set me in the right direction.


Now a word about beagles: never look a beagle directly in the eye.

Offline

#7 2012-08-20 03:26:53

Azuric
Member
Registered: 2012-08-16
Posts: 5

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Trilby wrote:

You can also have your bashrc call startx or xinit if it is logged into tty1.

This could easily be scripted to check for a keypress to login to some other WM, or not login to X at all.

After having played around with this a little, it seems not so easy.  I wrote a script that works, but the problem is that programs that run at startup through bashrc (and other bash startup files), xinitrc, inittab or rc.conf seem not to accept keyboard input.  I'm trying to get it to work through an inittab "custom keyboard request" action, but even this doesn't seem to be enabled until slim's already starting...

Any other ideas?

Last edited by Azuric (2012-08-20 03:28:41)


Now a word about beagles: never look a beagle directly in the eye.

Offline

#8 2012-08-20 07:16:15

Awebb
Member
Registered: 2010-05-06
Posts: 4,133

Re: [Solved] Choosing to autologin or not by pressing a key during boot

After reading this thread, I browsed the wiki a little to find this:

https://wiki.archlinux.org/index.php/Au … al_console
https://wiki.archlinux.org/index.php/Start_X_at_Boot

Have you worked yourself through them? There is even a part for an interactive login.

Offline

#9 2012-08-20 12:02:32

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,517
Website

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Azuric, I liked your idea so I implemented it for myself.  I already had autologin for tty1 set up, and I had an entry in my bashrc to start x whenever tty1 was logged into.  These both came right out of the wiki links that Awebb has posted.  But I realized it may be handy to 'cancel' the login to x and just get into tty1.  So I modified that part of my bashrc to look like this:

if [[ "$TERM" == linux ]] && [[ "$(tty)" == /dev/tty1 ]]; then
	read -s -n 1 -t 0.5 key
	[[ $? -eq 142 ]] && exec xinit
	case $key in ""|^[) ;; *) exec xinit ;; esac
fi

The result is that I will be logged into X automatically (provided autologin to tty1 is set in inittab).  But if I hold <ESC> or <ENTER> as tty1 is loging in it will cancel the starting of X and leave me at the tty.

The 0.5 sets the amount of time one has to hit one of these keys (half a second as is).  This seems to be enough for me.  If you set it higher, it will wait that long before starting X if you don't press any key.

edit: While this does what I want, I forgot to clarify how to get it to do what it sounds like you want.  Modify it to something like the following based on your WMs/DEs:

if [[ "$TERM" == linux ]] && [[ "$(tty)" == /dev/tty1 ]]; then
	read -s -n 1 -t 0.5 key
	[[ $? -eq 142 ]] && exec xinit
	case $key in
		""|^[) ;;
		o) exec xinit openbox ;;
		x) exec xinit xfce ;;
		*) exec xinit ;;
	esac
fi

Here pressing <Esc> or <Enter> will cancel logging in to X.  Pressing "o" will start openbox (provided xinitrc uses the parameter it is given), "x" will start xfce, and any other key - or no key at all after half a second - will start X with no parameter (aka a default WM).

Last edited by Trilby (2012-08-20 12:12:22)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#10 2012-08-20 16:39:54

Azuric
Member
Registered: 2012-08-16
Posts: 5

Re: [Solved] Choosing to autologin or not by pressing a key during boot

Sweet! Thanks guys! Hope this comes in handy for others.


Now a word about beagles: never look a beagle directly in the eye.

Offline

Board footer

Powered by FluxBB