Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

code to auto login without *dm

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
41 posts
  • Previous
  • 1
  • 2
Author
Message
sonix
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 102
Joined: Wed Feb 12, 2003 12:14 am

  • Quote

Post by sonix » Tue Feb 07, 2006 2:07 pm

should i replace @USER with @myusername or myusername?
do i need my password anywhere?
Top
sonix
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 102
Joined: Wed Feb 12, 2003 12:14 am

  • Quote

Post by sonix » Tue Feb 07, 2006 2:39 pm

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?
Top
broken_chaos
Guru
Guru
Posts: 370
Joined: Wed Jan 18, 2006 7:47 am
Location: Ontario, Canada

  • Quote

Post by broken_chaos » Tue Feb 07, 2006 9:22 pm

@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: Select all

source /etc/profile
That might not actually be necessary, but it doesn't cause any problems to be cautious.
Top
MerlinTheWizard
Apprentice
Apprentice
User avatar
Posts: 270
Joined: Sun Apr 06, 2003 1:23 am

  • Quote

Post by MerlinTheWizard » Mon May 08, 2006 10:11 pm

Nice, but is there any way to shut down the computer without having to type the shutdown command after logging out?
Top
broken_chaos
Guru
Guru
Posts: 370
Joined: Wed Jan 18, 2006 7:47 am
Location: Ontario, Canada

  • Quote

Post by broken_chaos » Thu May 11, 2006 11:22 pm

Write a script to do it for you.

Code: Select all

#!/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. ;)
Top
broken_chaos
Guru
Guru
Posts: 370
Joined: Wed Jan 18, 2006 7:47 am
Location: Ontario, Canada

  • Quote

Post by broken_chaos » Thu May 18, 2006 12:01 am

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.)

Code: Select all

#!/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 $?
}

Code: Select all

# /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.
Top
naseweis
Apprentice
Apprentice
Posts: 159
Joined: Fri Apr 04, 2003 2:17 am
Location: germany

  • Quote

Post by naseweis » Sat May 20, 2006 10:35 am

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.
Top
ryo-san
l33t
l33t
User avatar
Posts: 729
Joined: Thu Feb 17, 2005 7:52 pm

  • Quote

Post by ryo-san » Fri Jul 07, 2006 5:00 am

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.
Top
freez
n00b
n00b
User avatar
Posts: 37
Joined: Wed Sep 04, 2002 9:47 am
Location: austria

  • Quote

Post by freez » Thu Aug 31, 2006 8:46 am

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
Top
jwyeo2
n00b
n00b
User avatar
Posts: 9
Joined: Fri Nov 28, 2003 1:05 am

  • Quote

Post by jwyeo2 » Thu Sep 06, 2007 5:41 am

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.
Top
mudfly
n00b
n00b
User avatar
Posts: 22
Joined: Fri Apr 26, 2002 3:10 pm
Location: Austin, TX, Planet Earth
Contact:
Contact mudfly
Website

  • Quote

Post by mudfly » Thu Aug 14, 2008 2:18 pm

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.
Top
linuxtnt
n00b
n00b
Posts: 1
Joined: Tue Aug 26, 2008 3:28 pm

  • Quote

Post by linuxtnt » Wed Aug 27, 2008 6:04 pm

Thanks broken chaos , your script works like a charm
Top
pezzzz
n00b
n00b
Posts: 1
Joined: Fri Oct 24, 2008 9:17 am
Location: Mirano (VE) - Italy
Contact:
Contact pezzzz
Website

  • Quote

Post by pezzzz » Fri Oct 24, 2008 9:21 am

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 $?
}
Top
Fenril
Apprentice
Apprentice
Posts: 209
Joined: Sat May 16, 2009 8:04 am

  • Quote

Post by Fenril » Mon May 03, 2010 10:06 am

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: Select all

setenv("LANG", "fr_FR.UTF-8", 1);
Then i recompile it, but it doesn't help anymore. Any clue please ?
Top
Fenril
Apprentice
Apprentice
Posts: 209
Joined: Sat May 16, 2009 8:04 am

  • Quote

Post by Fenril » Tue May 04, 2010 11:27 am

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: Select all

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.
Top
eniac
Apprentice
Apprentice
User avatar
Posts: 233
Joined: Mon Aug 11, 2003 7:34 pm
Location: Belgium, Brussels

  • Quote

Post by eniac » Sun May 16, 2010 10:51 pm

I was trying the same thing before finding this post.

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

Code: Select all

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

Code: Select all

#!/bin/bash
exec login -f eniac
Next my .bash_profile contains:

Code: Select all

if [[ $(expr index "$(tty)" y) -ne 0   ]];
then   
        startx
fi
Turns out the pony only had one trick.
Top
Post Reply

41 posts
  • Previous
  • 1
  • 2

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic