2009年1月18日 星期日

更新到gdm-2.20以後custom session無法開啟?

最近更新 gnome 以後,輸入帳號密碼登入的時候竟然跳出了:
"你的 session 在10秒內登出~這是不正常的!"
這樣的錯誤訊息。但是我在 GDM 中按下 F10 叫出 session 選單,把原本的 session 由 custom 改成 Gnome 卻又可以正常登入。

我原本都是用 custom session 加上 ~/.xsession 來啟動 Gnome 。因為我有使用 SCIM 輸入法,這個輸入法如果沒有跑 "scim -d" 並且 "export XMODIFIERS=@im=SCIM" 的話,在 Java 程式中就別想使用中文輸入法了。

所以我把 gdm 中負責啟動 session 的那幾個 script 挖出來看,發現原來是 gdm 自己惹的禍。它原本應該在呼叫 exec 之前把 custom 轉換成 $HOME/.xsession 。但是不知道是寫錯了還是怎樣,它把轉換的動作放在呼叫 exec 之後。結果就是它跑了 "exec custom" ,這樣當然不會正常囉~

過程中我也發現gdm的session管理方式有改,變成一個session會對應到 "/etc/X11/xdm/dm" 下的一個 .desktop 檔案。 例如 gdm 中的 custom 會對應到 custom.desktop 這個檔案。現在倒是可以利用這檔案幫我把 custom session 搞回來。先來看一下這個檔案(這個檔案我做過了修改):
/etc/X11/dm/Sessions/custom.desktop:

[Desktop Entry]
Encoding=UTF-8
# The names/descriptions should really be better
Name=Lunker Session
Comment=This starts a custom session
#Exec=custom
Exec=$HOME/.xsession
# The "custom" Exec is a very special one and is handled specially in
# the Xsession script and just runs "~/.xsession" directly
Icon=
Type=Application

裡面的重點是 "Exec=custom" 這一行,這裡指定的就是 gdm 在準備好各種環境變數後要呼叫的 script。既然 gdm 沒有幫我們把 custom 換成 ~/.xsession ,那只好手動自己改囉。完成後再用 custom session 登入就沒有問題了。