Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
code to auto login without *dm
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2  
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
sonix
Tux's lil' helper
Tux's lil' helper


Joined: 12 Feb 2003
Posts: 102

PostPosted: Tue Feb 07, 2006 2:07 pm    Post subject: Reply with quote

should i replace @USER with @myusername or myusername?
do i need my password anywhere?
Back to top
View user's profile Send private message
sonix
Tux's lil' helper
Tux's lil' helper


Joined: 12 Feb 2003
Posts: 102

PostPosted: Tue Feb 07, 2006 2:39 pm    Post subject: Reply with quote

start-stop-daemon --start --pidfile /var/run/autostartx.pid --make-pidfile --exec /sbin/autostartx -- @USER

that command gives me an error "unable to start /sbin/autostartx: exec format error" anyone know how to correct this?
Back to top
View user's profile Send private message
broken_chaos
Guru
Guru


Joined: 18 Jan 2006
Posts: 315
Location: Ontario, Canada

PostPosted: Tue Feb 07, 2006 9:22 pm    Post subject: Reply with quote

@USER should be replaced by your username (i.e. justin is mine, so it's justin that I put there, not @justin).

Also, the wrapper shell script doesn't work. Just remove it and move /sbin/autostartx-bin to /sbin/autostartx.

And you'll want to put this line as the first line of your ~/.xinitrc or whatever file you use to start X:
Code:
source /etc/profile

That might not actually be necessary, but it doesn't cause any problems to be cautious.
Back to top
View user's profile Send private message
MerlinTheWizard
Apprentice
Apprentice


Joined: 06 Apr 2003
Posts: 270

PostPosted: Mon May 08, 2006 10:11 pm    Post subject: Reply with quote

Nice, but is there any way to shut down the computer without having to type the shutdown command after logging out?
Back to top
View user's profile Send private message
broken_chaos
Guru
Guru


Joined: 18 Jan 2006
Posts: 315
Location: Ontario, Canada

PostPosted: Thu May 11, 2006 11:22 pm    Post subject: Reply with quote

Write a script to do it for you.
Code:
#!/bin/bash
sudo /etc/init.d/autostartx stop
sudo reboot

This assumes you have a sudoers file setup to allow your user access to those commands without a password. You could also use gksu or similar instead, to add a graphical interface to it all.

I'm working on an ebuild for this, by the way, somewhat tweaked to work a bit better. ;)
Back to top
View user's profile Send private message
broken_chaos
Guru
Guru


Joined: 18 Jan 2006
Posts: 315
Location: Ontario, Canada

PostPosted: Thu May 18, 2006 12:01 am    Post subject: Reply with quote

I've found a much better way to do this, and will package this new method into an ebuild when I get the chance. For now, I'll tell the manual way. It's dead simple. ;) And much more flexible - no environment problems!

(For lack of confusion, and so you can try this out with the other method still on your box, I've changed the name of the init script to startx.)
/etc/init.d/startx:
#!/sbin/runscript

depend() {
   need local
   use xfs
}

start() {
   ebegin "Starting X11 as ${X11USER}"
   start-stop-daemon --start --background --quiet --pidfile ${PIDFILE} --make-pidfile --chdir ${X11HOME} --exec /bin/su -- ${X11USER} -lc "startx"
   eend $?
}

stop() {
   ebegin "Stopping X11 as ${X11USER}"
   start-stop-daemon --stop --quiet --oknodo --user ${X11USER} --pidfile ${PIDFILE}
   eend $?
}

/etc/conf.d/startx:
# /etc/conf.d/startx

# Set to the user you want auto-logged-in.
# Remember, this is terribly insecure.
# Only use this if you know what you're doing.
X11USER="username"

# Set this to your homedir. Probably /home/youruser.
X11HOME="/home/username"

# Pid file location. Probably don't need to touch this.
PIDFILE="/var/run/startx.pid"

1. Make these two files in the indicated locations.
2. chmod 755 /etc/init.d/startx
3. Edit /etc/conf.d/startx as appropriate for your user.
4. "/etc/init.d/startx start" as root to test it out. "/etc/init.d/startx stop" as root to stop your X11 instance.
5. "rc-update add startx default" as root to add it to your default runlevel. Works like a charm for me.
Back to top
View user's profile Send private message
naseweis
Apprentice
Apprentice


Joined: 04 Apr 2003
Posts: 159
Location: germany

PostPosted: Sat May 20, 2006 10:35 am    Post subject: Reply with quote

Looking for a way to auto-login a user (I didn't want to run startx but stay in vga), I found your threat and this *old* piece of documentation, which works like a charm: http://linuxgazette.net/issue72/chung.html
Running startx is included as well. If somebody still cares...
_________________
Nothing makes a person more productive than the last minute.
Back to top
View user's profile Send private message
ryo-san
l33t
l33t


Joined: 17 Feb 2005
Posts: 710

PostPosted: Fri Jul 07, 2006 5:00 am    Post subject: Reply with quote

hi

i do naseweis :D , moowei's method seems to freeze my keyboard on login with xorg 7.0, so i will give it a try.
Thx to both of you.
Back to top
View user's profile Send private message
freez
n00b
n00b


Joined: 04 Sep 2002
Posts: 37
Location: austria

PostPosted: Thu Aug 31, 2006 8:46 am    Post subject: Reply with quote

ryo-san, does it really freeze your keyboard, or does it just send your keyboard input to another tty?
_________________
apt-get is a dream but emerge is a wet dream
Back to top
View user's profile Send private message
jwyeo2
n00b
n00b


Joined: 28 Nov 2003
Posts: 9

PostPosted: Thu Sep 06, 2007 5:41 am    Post subject: Reply with quote

I was using moowei's autostartx-bin method for over a year and it was working fine. I brought my PVR system up to date to support schedules direct and the autostart didn't work any more. Tried a bunch of stuff, and many of them ran into the unresponsive keyboard. The reason for the keyboard issue is outlined in the comments in /etc/init.d/xdm, and indeed a garbled version my "ignored" keystrokes were being seen on vc2. Adding 'need local' to the depend() function seems to resolve the keyboard.

As a result of this, I am now using the scripts provided by broken_chaos that utilize su. I like that I no longer need to compile a helper binary. BTW, this method ran into the keyboard problem too as I had copied over some old depend() contents. Again, 'need local' fixed as posted did the trick.

Thanks to all - this is a great thread!

PS: I wondered at one point if it were possible to write a custom dm script that would work with the existing Gentoo xdm init scripts. If you were willing to place the user name in the dm script it would start, but for stopping I couldn't see a way to tell start-stop-daemon how to identify the process. Maybe someone with deeper knowledge than myself can figure it out.
Back to top
View user's profile Send private message
mudfly
n00b
n00b


Joined: 26 Apr 2002
Posts: 22
Location: Austin, TX, Planet Earth

PostPosted: Thu Aug 14, 2008 2:18 pm    Post subject: Reply with quote

The solution that broken_chaos provided still works like a charm. This is easy enough, but was there ever an ebuild created for this or something similar?
_________________
Give me your beer.
Back to top
View user's profile Send private message
linuxtnt
n00b
n00b


Joined: 26 Aug 2008
Posts: 1

PostPosted: Wed Aug 27, 2008 6:04 pm    Post subject: Reply with quote

Thanks broken chaos , your script works like a charm
Back to top
View user's profile Send private message
pezzzz
n00b
n00b


Joined: 24 Oct 2008
Posts: 1
Location: Mirano (VE) - Italy

PostPosted: Fri Oct 24, 2008 9:21 am    Post subject: Reply with quote

Found a problem with framebuffer decoration: console does not switch to X when startx is called. It needs a little sleep before startx:

start() {
ebegin "Starting X11 as ${X11USER}"
start-stop-daemon --start --background --quiet --pidfile ${PIDFILE} --make-pidfile --chdir ${X11HOME} --exec /bin/su -- ${X11USER} -lc "sleep 5; startx"
eend $?
}
Back to top
View user's profile Send private message
Fenril
Apprentice
Apprentice


Joined: 16 May 2009
Posts: 192

PostPosted: Mon May 03, 2010 10:06 am    Post subject: Reply with quote

Hello guys,

Sorry to up this old thread, but i would use this code to have an autologin on one of my computers. X is well launched but my locales aren't set correctly. I modified the code and put a line in autostartx-bin.c like this :

Code:
setenv("LANG", "fr_FR.UTF-8", 1);


Then i recompile it, but it doesn't help anymore. Any clue please ?
Back to top
View user's profile Send private message
Fenril
Apprentice
Apprentice


Joined: 16 May 2009
Posts: 192

PostPosted: Tue May 04, 2010 11:27 am    Post subject: Reply with quote

Fenril wrote:
Hello guys,

Sorry to up this old thread, but i would use this code to have an autologin on one of my computers. X is well launched but my locales aren't set correctly. I modified the code and put a line in autostartx-bin.c like this :

Code:
setenv("LANG", "fr_FR.UTF-8", 1);


Then i recompile it, but it doesn't help anymore. Any clue please ?


OK, i do so complicated... I've fixed it. Just add "env-update" in xinitrc file before running my DE.
Back to top
View user's profile Send private message
eniac
Apprentice
Apprentice


Joined: 11 Aug 2003
Posts: 233
Location: Belgium, Brussels

PostPosted: Sun May 16, 2010 10:51 pm    Post subject: Reply with quote

I was trying the same thing before finding this post.

The way I did it was edit /etc/inittab like this:
Code:

#c1:12345:respawn:/sbin/agetty 38400 tty1 linux
c1:12345:respawn:/sbin/agetty -n -l /root/bin/autologin 38400 tty1


autologin contains:
Code:

#!/bin/bash
exec login -f eniac

Next my .bash_profile contains:
Code:

if [[ $(expr index "$(tty)" y) -ne 0   ]];
then   
        startx
fi

_________________
Turns out the pony only had one trick.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum