早上花了 3 個小時研究,也到 /usr/local/etc/gdm/ 下面讀了 GDM 的相關 scripts,其中最為重要的就是 Xsession 這支程式。在 Xsession 之中,有一段是這麼寫的:
if [ "x$command" = "xcustom" ] ; then
if [ -x "$HOME/.xsession" ]; then
command="$HOME/.xsession"
else
echo "$0: Cannot find ~/.xsession will try the default session"
command="default"
fi
fi
乍看之下,GDM 會有條件執行 ~/.xsession,只要 $command 的內容是 "custom" 即可,於是一開始便朝這方向嘗試。不過 GDM 是在開機時由 FreeBSD 自動喚起(/etc/rc.conf 設定 gdm_enable="YES"),不曉得要如何將 "custom" 做為 Xsession 的參數傳遞進去。思考幾分鐘後決定放棄,改朝其他方向嘗試。
皇天不負苦心人,後來讓我在 FreeBSD mailing list 裡撈到一篇有關 GDM 設定的討論文章(http://lists.freebsd.org/pipermail/freebsd-questions/2006-April/119887.html),其內容摘錄如下:
So... I had found a few HowTo's on customizing GDM on the web. All said
similar things but nothing worked for me. What they said to do *was*
important, and in fact was 99% of the work. So here's what I did to get
GDM to run my .xsession file (last step did the trick):
1) install /x11/gdm
2) make sure you have an ~/.xsession file (setup however you like)
3) make sure you have #!/bin/sh as first line
4) make sure ~/.xsession is executable
5) create a file /usr/X11R6/etc/gdm/Sessions/MySession.desktop
(replace MySession with whatever name you like)
6) Give it the following contents
[Desktop Entry]
Encoding=UTF-8
Name=XSession
Comment=This session will run your ~/.xsession
Exec=~/.xsession
Icon=
Type=Application
(feel free to change name and comment to liking)
7) Edit your /usr/X11R6/etc/gdm/gdm.conf. Search for
SessionDesktopDir. In my conf file it was commented out (plus a typo).
So I created a new SessionDesktopDir and pointed it where I placed my
*.desktop file. Such as SessionDesktopDir=/usr/X11R6/etc/gdm/Sessions/.
That's it. My new session is now visible, and runs my .xsession
seemingly just as XDM had.
There's plenty of eye candy for GDM. I'm sure there is a port in ports
that will install some, but haven't looked. I simply copied a dir of
themes from a gentoo box.
重點其實是在 GDM 的 session 設定檔中(/usr/X11R6/etc/gdm/Sessions/*.desktop;在我的系統上是 /usr/local/share/xsessions/*.desktop),將 *.desktop 設定檔之中的 exec 鍵值改為 ~/.xsession 則此問題馬上迎刃而解。
真是可喜可賀。
沒有留言:
張貼留言