views:

904

answers:

7

What is the easiest and most elegant way to log into a fluxbox session automatically (with no action necessary, no keypress or anything) on system startup as a certain user. [Edit 2] Not even a shell login should be necessary for the user, always the preset user should be logged in graphically. [/Edit 2]

There are some setups where this is nice.

(Please put remarks about whether this should be discussed at all or better kept secret to the other question: http://stackoverflow.com/questions/747008/is-it-good-to-make)

[EDIT 1]

How could I lock fluxbox immedeately then (using xtrlock) but at the same keep starting my favourite applications.

The result would be: I switch on the box, go and have breakfast, when I come back I unlock the box with my password (accepted by xtrlock) and everything is in place.

Is it impossible or how could it be done to break this scheme in "edit 1", imagine someone presses ctrl-c at the right time when fluxbox is coming up or whatever is possible. Or that person could use the mouse to klick somewhere in an application that start before xtrlock prevents it.

(I am aware of the fact that someone might see the contents of the screen but that would be ok for me.)

[/EDIT 1]

+3  A: 

On gentoo you have the file /etc/conf.d/local.start for this. Your distribution probably has a similar file, where you can setup commands to be executed at startup.

There you add this line:

su -c "startx" $user &

In the home directory of $user you can setup the .xinitrc to run fluxbox by adding this at the last line:

exec startfluxbox

If you need to run any more programs, prepend them in the .xinitrc. Note that the exec startfluxbox has to be run as the last.

+3  A: 

On debian I have a script (lets call it autologin.sh) which launches X11:

su - kit -c "startx &"

Which is in turn installed via update-rc.d:

sudo update-rc.d autologin.sh defaults 99 1

I also disable all login managers like {k,g,x}dm. Then in ~/.xinitrc I would have:

$command 1 &
$command 2 &
x-window-manager
freespace
i should replace the last line "x-window-manager" with "exec startfluxbox" in my case?
x-window-manager is maintained by the system to point to the window manager of your choice. Follow the symlinks to see this. You can change it, though I don't: that way when I install a new WM, I don't need to change the script :) This will also allow any WM-specific startup scripts to run.
freespace
i found out that autologin.sh should live in /etc/init.d/
+5  A: 

I suppose you use GDM login manager. In its configuration file /etc/gdm/gdm.conf enable autologin feature:

AutomaticLoginEnable=true
AutomaticLogin=karlthorwald

You can also define a timeout for automatic logins. Restart gdm and voilà!

jetxee
+1  A: 

From your question I deduce that you want to start a XWindow session automatically after somebody makes a login from the console.

A solution that works for any distribution is to use the .profile in the user home directory (see the bash reference manual for details). All you have to place in it are the commands that you want executed automatically by the user at login. In your case it should be something like this:

#Start the XWindow session
startx
#Exit the shell once the XWIndow session is done
exit

On a side note, you can always look at There is always GDM (often part of the gnome package), KDM (often part of a KDE package) or XDM that can start a X automatically at boot time using an rc script and then get you to your favorite Window Manager once you've logged in. GDM and KDM both offer a way to automatically login a user if that's what you are looking for. GDM, KDM and XDM are comparable to Mac OS X login window or the Microsoft Windows login window.

Pierre-Luc Simard
sorry for my unclear question. no, I am looking for a totally auto loging without typing a username or password or even touching a key. sorry for my bad english.
Then using the .profile file should work fine for you. (see first part of my answer)
Pierre-Luc Simard
+1  A: 

Use the /etc/inittab file. This file spawns login shells and perhaps a display manager (like [GK]DM) when your computer enters runlevel 5 (normally).

A default login shell line make look like this:

c1:2345:respawn:/sbin/agetty -8 38400 vc/1 linux

However, with agetty, you can specify your own login program. So, replace with something like this

c1:2345:respawn:/sbin/agetty -n -l /usr/local/sbin/auto_login 38400 vc/1 linux

And then auto_login.c

#include <unistd.h>
int main() {
       execlp( "login", "login", "-f", "your_user_name_here", 0);
}

Now use your shells startup script to start X like you want to.

gnud
+4  A: 

You can also use rungetty. It is designed specifically as a getty replacement that 'runs' something. So, you can set it to startx, run fluxbox and what nots.

sybreon
+3  A: 

Ok, there's numerous answers for the automatic login - it's a feature of kdm & gdm, or can be done by starting x explicitly rather than using a display manager, etc.

As for the locking part, there's a file you can play with:

/home/<user>/.fluxbox/startup

At the start of the file add in the following lines:

/usr/bin/xtrlock &
/usr/bin/sleep 5

xtrlock, does what you want with the session locking. The ampersand means do it in the background - carry straight on with the next command, the sleep helps to ensure that the screen is locked before any other applications are started.

Notice that the last line of this startup file is the line that actually runs fluxbox, so this runs way before any applications start up.

In terms of security, I don't think you can press ctrl-c to get around it, but security is obviously less tight than in the full login scenario.

Jim T