public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] xinitrc/startx scripts unification
@ 2006-09-10 11:56 Lukasz Pawelczyk
  2006-09-12 21:42 ` Donnie Berkholz
  0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Pawelczyk @ 2006-09-10 11:56 UTC (permalink / raw
  To: gentoo-dev

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

I wanted to fill bugzilla report about this but found few existing
without neither serious solution nor being current.

There is an incosistency in current xinitrc behaviour (i'm only talking
about xinitrc run through startx, not {k,g,x}dm).

Problems:

1. /etc/X11/xinitrc tries to load xresources and xmodmap but not xkb,
this is done only in /etc/X11/Sessions/Xsession so to use it you need to
set XSESSION=Xsession (not giving yourself a chance to use chooser for
chosing windowmager which is i think it should be used for)

2. neither of them sources /etc/X11/xinit/xinitrc.d not letting f.e.
dbus to start in your session

3. /etc/X11/xinitrc tries to load ~/.xinitrc which is absolutely
unneccesary as this is done in startx and running ~/.xinitrc from
/etc/X11/xinitrc wont ever happen (and it should work this way as
~/.xinitrc should be run on totally clean session, without any
resources/modmaps set, for the other case ~/.xsession or ~/.Xclients
should be used)

4. Most of this is workarounded f.e. in /etc/X11/Sessions/Gnome which
does all whats necessary (xkb, xinitrc.d) but this is just code
duplication with /etc/X11/Sessions/Xsession and requires other wm's
sessions do the same and they dont. F.e. windowmaker,
/etc/X11/Sessions/wmaker only runs wmaker bin, without setting anything.

Solution:

Completely remove /etc/X11/Sessions/Xsession and merge its functionality
with /etc/X11/xinitrc + add sourcing xinitrc.d (see attachment #1).
Remove all resource related things from /etc/X11/Sessions/* and make
these files only run windowmagers. All other things would be done from
/etc/X11/xinitrc for all windowmagers.
Gnome session after this should look like attachment #2.

All of these changes shouldn't break anything.
If someone is setting XSESSION to Xsession to rely on ~/.xsession,
/etc/X11/xinitrc will do it by default.
If someone set XSESSION to any other windowmanager it will work as well
(chooser is still run from /etc/X11/xinitrc) but in addition he'll have
properly set enviroment for wm's that dont it themselves (above example
of wmaker).

The only thing that will change is when someone have both XSESSION set
and ~/.xsession created. Now ~/.xsession will have priority over chooser
as it should be in my opinion. If you think this is unacceptable its
only enough to change order in xinitrc proposed by me.

Patch #3 is /etc/X11/Sessions/Xsession against new xinitrc.

What do you think about it? If you'd accept it I'd happily review other
wm's session files as well.

-- 
Regards
Lukas Pawelczyk

[-- Attachment #2: xinitrc --]
[-- Type: text/plain, Size: 2514 bytes --]

#!/bin/sh

# redirect errors to a file in user's home directory if we can
for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
do
	if ( cp /dev/null "$errfile" 2> /dev/null )
	then
		chmod 600 "$errfile"
		exec > "$errfile" 2>&1
		break
	fi
done

# clean up after xbanner
if which freetemp 2> /dev/null ; then
	freetemp
fi

startup=$HOME/.xsession

userresources=$HOME/.Xresources 
usermodmap=$HOME/.Xmodmap 
userxkbmap=$HOME/.Xkbmap

sysresources=/etc/X11/Xresources 
sysmodmap=/etc/X11/Xmodmap 
sysxkbmap=/etc/X11/Xkbmap

rh6sysresources=/etc/X11/xinit/Xresources 
rh6sysmodmap=/etc/X11/xinit/Xmodmap 


# merge in defaults
if [ -f "$rh6sysresources" ]; then
    xrdb -merge "$rh6sysresources"
fi

if [ -f "$sysresources" ]; then
    xrdb -merge "$sysresources"
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

# merge in keymaps
if [ -f "$sysxkbmap" ]; then
    setxkbmap `cat "$sysxkbmap"`
    XKB_IN_USE=yes
fi

if [ -f "$userxkbmap" ]; then
    setxkbmap `cat "$userxkbmap"`
    XKB_IN_USE=yes
fi

#
# Eeek, this seems like too much magic here
#
if [ -z "$XKB_IN_USE" -a ! -L /etc/X11/X ]; then
    if grep '^exec.*/Xsun' /etc/X11/X > /dev/null 2>&1 && [ -f /etc/X11/XF86Config ]; then
       xkbsymbols=`sed -n -e 's/^[     ]*XkbSymbols[   ]*"\(.*\)".*$/\1/p' /etc/X11/XF86Config`
       if [ -n "$xkbsymbols" ]; then
           setxkbmap -symbols "$xkbsymbols"
           XKB_IN_USE=yes
       fi
    fi
fi

# xkb and xmodmap don't play nice together
if [ -z "$XKB_IN_USE" ]; then
    if [ -f "$rh6sysmodmap" ]; then
       xmodmap "$rh6sysmodmap"
    fi

    if [ -f "$sysmodmap" ]; then
       xmodmap "$sysmodmap"
    fi

    if [ -f "$usermodmap" ]; then
       xmodmap "$usermodmap"
    fi
fi

unset XKB_IN_USE

# run all system xinitrc shell scripts.
if [ -d /etc/X11/xinit/xinitrc.d ]; then
    for i in /etc/X11/xinit/xinitrc.d/* ; do
        if [ -x "$i" ]; then
	    . "$i"
        fi
    done
fi

if [ -x "$startup" ]; then
	exec "$startup"
elif [ -x "$HOME/.Xclients" ]; then
	exec "$HOME/.Xclients"
# If not present, try the system default
elif [ -n "`/etc/X11/chooser.sh`" ]; then
	exec "`/etc/X11/chooser.sh`"
elif [ -x /etc/X11/xinit/Xclients ]; then
	exec /etc/X11/xinit/Xclients
elif [ -x /etc/X11/Xclients ]; then
	exec /etc/X11/Xclients
# Failsafe
else
	# start some nice programs
	twm &
	xclock -geometry 50x50-1+1 &
	xterm -geometry 80x50+494+51 &
	xterm -geometry 80x20+494-0 &
	exec xterm -geometry 80x66+0+0 -name login
fi

[-- Attachment #3: Gnome --]
[-- Type: text/plain, Size: 466 bytes --]

#!/bin/sh

# Great new Gnome2 feature, AA
# We enable this by default

export GDK_USE_XFT=1

if [ -x "$HOME/.gnomerc" ]; then
	command="$HOME/.gnomerc"
elif [ -x /etc/X11/gdm/gnomerc ]; then
	command="/etc/X11/gdm/gnomerc"
else
	# as fallback in case the config is screwed
	command=`which gnome-session`
fi

sshagent=`which ssh-agent`
if [ -n "$sshagent" ] && [ -x "$sshagent" ] && [ -z "$SSH_AUTH_SOCK" ]; then
    command="$sshagent -- $command"
fi

exec $command

[-- Attachment #4: xinitrc.diff --]
[-- Type: text/plain, Size: 1285 bytes --]

--- /usr/portage/x11-apps/xinit/files/Xsession	2005-08-14 02:12:39.000000000 +0200
+++ xinitrc	2006-09-10 13:50:51.000000000 +0200
@@ -1,14 +1,4 @@
 #!/bin/sh
-# $XConsortium: Xsession /main/10 1995/12/18 18:21:28 gildea $
-
-case $# in
-1)
-	case $1 in
-	failsafe)
-		exec xterm -geometry 80x24-0-0
-		;;
-	esac
-esac
 
 # redirect errors to a file in user's home directory if we can
 for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
@@ -94,14 +84,32 @@
 
 unset XKB_IN_USE
 
+# run all system xinitrc shell scripts.
+if [ -d /etc/X11/xinit/xinitrc.d ]; then
+    for i in /etc/X11/xinit/xinitrc.d/* ; do
+        if [ -x "$i" ]; then
+	    . "$i"
+        fi
+    done
+fi
+
 if [ -x "$startup" ]; then
 	exec "$startup"
 elif [ -x "$HOME/.Xclients" ]; then
 	exec "$HOME/.Xclients"
+# If not present, try the system default
+elif [ -n "`/etc/X11/chooser.sh`" ]; then
+	exec "`/etc/X11/chooser.sh`"
 elif [ -x /etc/X11/xinit/Xclients ]; then
 	exec /etc/X11/xinit/Xclients
 elif [ -x /etc/X11/Xclients ]; then
 	exec /etc/X11/Xclients
+# Failsafe
 else
-	exec xsm
+	# start some nice programs
+	twm &
+	xclock -geometry 50x50-1+1 &
+	xterm -geometry 80x50+494+51 &
+	xterm -geometry 80x20+494-0 &
+	exec xterm -geometry 80x66+0+0 -name login
 fi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-12 21:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-10 11:56 [gentoo-dev] xinitrc/startx scripts unification Lukasz Pawelczyk
2006-09-12 21:42 ` Donnie Berkholz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox