public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: gibboris@gmail.com
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] start X at startup without a login manager
Date: Sun, 22 Mar 2009 14:00:53 +0100	[thread overview]
Message-ID: <20090322130053.GA6292@b1b1.lan> (raw)
In-Reply-To: <5cd9791d0903200809h27b4704ci9c44cb00a9561ee@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3553 bytes --]

I was thinking about the proper way to set-up the autologin some time
ago.
Some hints which came to my mind :
1) should be started as a service so restart/start/stop may be used and
doesn't leave an open root shell
2) should be restarted with ctrl+alt+backspace without losing the
keyboard focus (may be a problem when not using telinit)
3) try to avoid the numerous wrappers of login managers in /etc/X11
4) should be able to come back to login manager by modifying only one
conf.d file (or env.d ?)
--- so below is the way I have set it up for the moment :
I did a kind of merge of the xdm and startUS.sh (script found on the
gentoo forums) so I don't have x11-apps/xdm but I have a xdm init script 
(which should have another name but it's just a modified version of the
original xdm script)
[xdm patch attached]
To avoid the unresponsive keyboard : I always use telinit so :
x:a:once:/etc/X11/startDM.sh
is appended in my /etc/inittab.

In startDM.sh a modification is done to make start-stop-daemon drop its
privs and set the minimum env needed by startx then xinit.
[startDM.sh patch attached]

Notice two facts : env X=y start-stop-daemon is used because I was not
able to use several --env options.
My user's .xinitrc sources its .bash_profile (which source /etc/profile)
to initialize the other variables.
(I would like to export the bash completion to my whole X session, but it's
another problem...)

An alternative is the make start-stop-daemon launch 'su -- -l'
but it's dirty because of the need to store the pid.

So the first problem is that the xdm script doesn't know the pid of xinit
because even without 'su', start-stop-daemon knows about startx, not
xinit.
The second one is that ctrl+alt+backspace isn't trapped correctly.
Should 'xinit restart' be the direct work of the daemon in the autologin
case ?
In the autologin case which imho implies the user has a .xinitrc, startx
is only useful for the 2 or 3 lines around mcookie.
Should startx be directly in /etc/init.d .
(as said in the header it's a old sample of this script) and the deep
meaning of runlevel (multiuser / graphic) should be think from the
beginning to understand the right way to organise the X11 launch stuff.
What about putting startx's $defaultserverarg and $enable_xauth in a
/etc/conf.d/xdm (or better : /etc/conf.d/xinit) ?

(the local.start is a hacky but short and understandable way to do
though :), a quick heavier case is there : http://www.gentoo-wiki.info/TIP_Passwordless_Login)
Anyway, I'm still a bit lost in the quest of the cleanest way
from system init to ~/xinitrc.
So any comment, advice, whatever ... would be greatly appreciated.

Raph

On Fri, Mar 20, 2009 at 11:09:56PM +0800, fei huang wrote:
> I don't have any "xdm", "gdm" stuff but would like to start my windows
> manager directly at startup, cause I'm the only one that use it.
> 
> here is my solution:
> I use runlevel 3 as default, and add a line of code in
> "/etc/conf.d/local.start":
> 
> su - myname -c startx&
> 
> this works just fine except my scim panel would not shown as before, but if
> I login in normally with my user name, and type "startx" manually,
> everything works perfect. I'm wondering what is the difference with those
> two steps that cause the problem,
> "ps" shows the scim processes  are just running normally, for reference, I
> pasted my "xinitrc" here:
> 
> export XMODIFIERS='@im=SCIM'
> export GTK_IM_MODULE=scim
> scim -d
> 
> xrdb -merge ~/.Xresources
> urxvtd -q -f -o
> 
> conky -q &
> 
> exec awesome
> 
> 
> any ideas?
> 
> thanks
> 
> fei

[-- Attachment #2: init.d_xdm.patch --]
[-- Type: text/plain, Size: 781 bytes --]

--- xdm.old	2009-02-06 12:11:29.000000000 +0100
+++ xdm	2009-02-06 12:15:53.000000000 +0100
@@ -85,6 +85,12 @@
 			EXE=/usr/bin/wdm
 			PIDFILE=
 			;;
+		none)
+			test -n "$(id -u ${XUSER} 2>/dev/null)" && \
+			EXE=/usr/bin/startx \
+			PIDFILE=/var/run/x.pid \
+			NAME=startx
+			;;
 		*)
 			EXE=
 			# Fix #65586, where MY_XDM is empty so EXE=somedir
@@ -140,6 +146,7 @@
 	save_options "service" "${EXE}"
 	save_options "name"    "${NAME}"
 	save_options "pidfile" "${PIDFILE}"
+	save_options "xuser"	"${XUSER}"
 
 	if [ -n "${CHECKVT-y}" ] ; then
 		if vtstatic "${CHECKVT:-7}" ; then
@@ -154,7 +161,11 @@
 		fi
 	fi
 	
-	/etc/X11/startDM.sh
+	if [ -n "${XUSER}" ] && [ -x /sbin/telinit ]; then
+		telinit a >/dev/null 2>&1
+	else
+		/etc/X11/startDM.sh
+	fi
 	eend 0
 }
 

[-- Attachment #3: X11_startDM.sh.patch --]
[-- Type: text/plain, Size: 1032 bytes --]

--- startDM.sh.old	2009-03-22 00:33:04.000000000 +0100
+++ startDM.sh	2009-03-22 00:34:32.000000000 +0100
@@ -14,17 +14,27 @@
 	[ -r "${svclib}"/sh/rc-services.sh ] && . "${svclib}"/sh/rc-services.sh
 fi
 
-# Great new Gnome2 feature, AA
-# We enable this by default
-export GDK_USE_XFT=1
 export SVCNAME=xdm
 
 EXEC="$(get_options service)"
 NAME="$(get_options name)"
 PIDFILE="$(get_options pidfile)"
+XUSER="$(get_options xuser)"
+
+if test -z "${XUSER}"; then
+	# Great new Gnome2 feature, AA
+	# We enable this by default
+	export GDK_USE_XFT=1
+
 
 	start-stop-daemon --start --exec ${EXEC} \
 	${NAME:+--name} ${NAME} ${PIDFILE:+--pidfile} ${PIDFILE} || \
 	eerror "ERROR: could not start the Display Manager"
+else
+        env USER=${XUSER} HOME=$(getent passwd ${XUSER}|cut -d: -f6) \
+        start-stop-daemon --start --background --make-pidfile -c ${XUSER} --exec ${EXEC} \
+        ${NAME:+--name} ${NAME} ${PIDFILE:+--pidfile} ${PIDFILE} || \
+	eerror "ERROR: could not start ${EXEC} for ${XUSER}"
+fi
 
 # vim:ts=4

  parent reply	other threads:[~2009-03-22 13:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20 15:09 [gentoo-user] start X at startup without a login manager fei huang
2009-03-20 16:16 ` [gentoo-user] " Nikos Chantziaras
2009-03-20 20:27   ` Sebastian Günther
2009-03-21  2:28   ` Tom
2009-03-21  3:28     ` fei huang
2009-03-20 18:09 ` [gentoo-user] " Florian Philipp
2009-03-20 18:21   ` Joshua D Doll
2009-03-20 18:43   ` James Ausmus
2009-03-20 20:22   ` Sebastian Günther
2009-03-21  7:14     ` Florian Philipp
2009-03-20 20:33 ` Sebastian Günther
2009-03-20 20:34 ` Paul Hartman
2009-03-25 20:03   ` Mick
2009-03-25 20:20     ` Sebastian Günther
2009-03-25 20:22     ` Paul Hartman
2009-03-22 13:00 ` gibboris [this message]
2009-03-23  4:19   ` fei huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090322130053.GA6292@b1b1.lan \
    --to=gibboris@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox