而且当进入系统后,却没有桌面,panel倒是有的。这时如果你查看进程,(可以用终端命令ps,或者图形工具gnome-system-monitor等等),会发现nautilus进程占用了很高的进程,这说明nautilus桌面管理程序它是启动了,可是异常了。我相信这是7.04,7.10版本的一个bug,我尝试过登出再登录许多次,nautilus时灵时不灵,而且灵的时候少,不灵的时候多。 你可以kill它,然后重新start它(直接用命令nautilus就可以了,它会自动Initialize gnome-mount extension挂载你windows的盘如果你有的话),这时美丽的桌面又回来了。
但是,这还是没有解决根本的问题。难道每次都要这样等待吗?我尝试过而且花了很多时间在网上google,baidu过,可是没有找到过可行的办法,因此我决定自己来看看能不能解决,这样就要对gdm管理,gnome-session相关使用到的文件有个必要的了解,查看/etc/gdm下的文件发现gdm.conf和gdm.conf-custom(在它们的头部有段英文有说明)的关系,你用系统/系统管理/登录窗口(也就是gdmsetup)对里面的修改都将反应到gdm.conf-custom中。还有Xsession真正管理会话的脚本,感兴趣的不妨看看它,
里面有一段:
代码: 全选
# use run-parts to source every file in the session directory; we source
# instead of executing so that the variables and functions defined above
# are available to the scripts, and so that they can pass variables to each
# other
SESSIONFILES=$(run_parts $SYSSESSIONDIR)
if [ -n "$SESSIONFILES" ]; then
for SESSIONFILE in $SESSIONFILES; do
. $SESSIONFILE //看这里,其实它这是在循环执行$SYSSESSIONDIR也就是/etc/X11/Xsession.d中的脚本
done
fi
刚开始我没有删除它只是将/etc/X11/Xsession.d中它新增加的一个文件98xserver-xgl_start-server删除(最好备份),你看看它就会发现真正执行的是/usr/share/xserver-xgl/Xgl-session,你再看看/usr/share/xserver-xgl下的另一个文件,你会发现其实它的自动让xgl运行也不是多么神奇!别害怕它。我也是刚使用ubuntu不久,对脚本也不熟,对C++倒是还好(专业课)。即使都不懂,你看看那些文件的头部说明也能有个大概的了解的。
废话了些,继续正题,上面这一段是我对xserver-xgl的兴趣,没兴趣的大可以直接sudo apt-get remove xserver-xgl。恩,省事!不过,请注意这是对装nv官方驱动的来说的,其他的情况请谨慎!
还挺难说清楚的,待续吧。
续上:
当选择会话时,有四个选项,重点说gnome,和运行Xclient脚本两个选项。
当选择gnome时,gnome-session会首先到~/gnome2下看看有没有一个叫session的文件,有的话就按照它来进行下一步。没有的话,就按照/usr/share/gnome下的default.session来进行下一步。
先看看default.session文件:
代码: 全选
# This is the default session that is launched if the user doesn't
# already have a session.
# The RestartCommand specifies the command to run from the $PATH.
# The Priority determines the order in which the commands are started
# (with Priority = 0 first) and defaults to 50.
# The id provides a name that is unique within this file and passed to the
# app as the client id which it must use to register with gnome-session.
# The clients must be numbered from 0 to the value of num_clients - 1.
[Default]
num_clients=6
0,id=default0
0,Priority=10
0,RestartCommand=gnome-wm --sm-client-id default0
1,id=default1
1,Priority=40
1,RestartCommand=gnome-panel --sm-client-id default1
2,id=default2
2,Priority=40
2,RestartCommand=nautilus --no-default-window --sm-client-id default2
3,id=default3
3,Priority=60
3,RestartCommand=gnome-cups-icon --sm-client-id default3
4,id=default4
4,Priority=40
4,RestartCommand=gnome-volume-manager --sm-client-id default4
5,id=default5
5,Priority=50
5,RestartCommand=vino-session --sm-client-id default5
你使用系统/首选项/会话,添加的程序,都会放进~/.config/autostart.以.desktop作为文件名后缀。在系统刚刚进入桌面,你先别运行其他程序,而点进系统/首选项/会话,选择“当前会话”标签,就可以看到所有default.session指定的程序和autostart里面的程序了。
相信大家都在用beryl吧,要想让系统使用beryl作为窗口管理器,你可以修改default.session中的"gnome-wm"为“beryl”。但是不提倡这么做,你可以复制它到~/gnome2命名为session(直接用命令sudo cp /usr/share/gnome/default.session ~/gnome2/session就行了),然后对session进行修改。就可以屏蔽default.session了。原理上面说过。
当然你可以将里面你自己认为不需要的程序给注释或删除。不过要注意符合它的规则。
我的session文件:
代码: 全选
# This is the default session that is launched if the user doesn't
# already have a session.
# The RestartCommand specifies the command to run from the $PATH.
# The Priority determines the order in which the commands are started
# (with Priority = 0 first) and defaults to 50.
# The id provides a name that is unique within this file and passed to the
# app as the client id which it must use to register with gnome-session.
# The clients must be numbered from 0 to the value of num_clients - 1.
[Default]
num_clients=4
0,id=default0
0,Priority=10
#0,RestartCommand=gnome-wm --sm-client-id default0
0,RestartCommand=beryl --sm-client-id default0
1,id=default1
1,Priority=30
1,RestartCommand=nautilus --no-default-window --sm-client-id default1
2,id=default2
2,Priority=40
2,RestartCommand=gnome-panel --sm-client-id default2
3,id=default3
3,Priority=40
3,RestartCommand=gnome-volume-manager --sm-client-id default3
由于7.04和7.10的nautilus的那个bug(上面说过),不知道你们的是不是也是和我一样。我也搞不定,所以替代方法是将session文件中nautilus对应的那三行也删除,先不自动运行它,等进入系统后自己来通过命令来启动它,这样就不需要等待很长时间才能使用系统了。
现在说说另一个登录选项“运行Xclient脚本”。
先找到/usr/share/gdm/BuiltInSessions目录下,你会发现一个文件“运行Xclient脚本”,其实它真正的文件名是default.desktop.
你可以将它拖进gedit里面。
在文件的最后一段是:
代码: 全选
Comment[zh_CN]=此会话将运行 Xclients 脚本
Exec=default
# The "default" Exec is a very special one and is handled specially in
# the Xsession script, you could also have "custom" which would just run
# "~/.xsession" directly
Icon=
Type=Application
X-Ubuntu-Gettext-Domain=gdm
# The "default" Exec is a very special one and is handled specially in
# the Xsession script, you could also have "custom" which would just run
# "~/.xsession" directly
注意理解以上这一段的意思。它说"default"默认是由Xsession脚本进行特殊处理的。我们可以自己写段脚本在~/.xsession里,这样它就将直接运行我们写的脚本了。
先写这些,不知道我说的够不够清楚了,大致上就是这样。事实上我写这篇文章是想看看自己能不能将想说的正确的表达出来分享给有需要的朋友。同时也算是自己这段时间使用学习ubuntu的小结。
忠告或建议:在使用命令的时候尽量知道它所起到的效果,这样当发现不妥时好补救!有兴趣的话,多了解些运行的机制。尽量自己思考解决问题,这样可以促进学习。
我说写的这篇文章,是自己通过摸索,(使用find,locate,man等等命令找出相关的文件阅读它们),而得到的对登录和会话管理的理解。肯定会有错误或不够完善的地方(也可能我没有描述详尽造成误解),希望大家可以指出来。
另外,转载请注明出处,谢谢。
---lionkingfly 2007-9-23