SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-07-18 01:28:21

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Automatic login and `startx` without a display manager in BunsenLabs

ExecStart=-/sbin/agetty -a <user name> %I $TERM

Last edited by Head_on_a_Stick (2015-07-18 18:59:25)

Offline

Be excellent to each other!

#2 2015-07-18 08:44:17

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 4,148
Website

Re: Automatic login and `startx` without a display manager in BunsenLabs

...it is in fact possible to do something like this even for more than one user. (Only feasable in a family or other high-trust environment of course.) You need to invoke a script which decides on the user and then logs them in. On Wheezy I've got a test setup like that running OK on a laptop, but haven't tried on Jessie. It might work though.

If you're not afraid of breaking your login, change that first line to:

ExecStart=-/sbin/agetty -n -l /usr/local/sbin/select-autologin %I $TERM

And that select-autologin can be quite simple, but the thing I have (with colours) is:

#!/bin/bash
# select-autologin
# login main user (Jim) if any key pressed, otherwise default user (John)

timeout=4 # seconds till default user logs in

#aplay -D plughw -q /usr/local/share/sounds/nature2.wav & apid=$!

STYLE="$( tput -S <<EOF
setab 4
setaf 3
bold
EOF
)"

NORM="$( tput sgr0 )"

countdown() { # $1 is seconds to countdown, $2 is string to show before count
local i=$1
while (($i>0))
do
    printf "\r%s" "${2}${i} seconds  "
    ((i--))
    sleep 1
done
}

echo $STYLE
clear
echo "	***LOGIN***

Jim, press any key to login.
" # adjust to name of main user

countdown $timeout 'John will log in in '  & pid=$! # name of default user

read -t $(( $timeout )) -srn1 && {
	[[ $apid ]] && {
		kill $apid
		wait $apid 2>/dev/null
	}
	kill $pid
	wait $pid 2>/dev/null
	echo $NORM
	clear
	exec /bin/login -f jim
}

[[ $apid ]] && {
	kill $apid
	wait $apid 2>/dev/null
}
[[ $pid ]] && {
	kill $pid
	wait $pid 2>/dev/null
}
echo $NORM
clear
exec /bin/login -f john

exit 

So do nothing and John logs in after x seconds, hit any key and Jim logs in. Consider enabling (and possibly editing) the aplay line to get audible warning that the login screen is up. It looks now even more nasty and bloated than I remember, but sort of works...

Offline

#3 2015-07-18 08:58:57

Head_on_a_Stick
CatMod
From: A world of pure imagination
Registered: 2014-01-21
Posts: 4,797

Re: Automatic login and `startx` without a display manager in BunsenLabs

^ Nice!

Thanks johnraff smile

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: bleh

Debian Logo