這陣子設定一台閒置的 MacPro 2013, 安裝成 MacOS 與 Ubuntu 雙開機,且想順便試一下 Wayland. 由於平日都是用 tiling window manager, 就想用用看 sway. 試了試感覺還不錯,就想把目前工作用的筆電也切到 i3 好了。畢竟原先用的 awesome 先前是說沒有移植到 Wayland 的計畫,而 sway 就是作為 i3 的 drop-in replacement on Wayland, 這樣工作環境比較統一。當然,也是有 Wayback 這種看起來超棒的專案,做起來的話就不需要 XWayland 這麼克難的方式跑了,但經驗告訴我,都已經用冷門東西了,最好是選冷門裡面最熱門的…
趁這機會,也想把啟動 X11 的方法改為 startx, 也就是跳過 display manager, 用 Ctrl-Alt-F2 切到 console 直接 login 然後執行 startx. 當然也可以直接移除 gdm3, 不過我都還是會留著 Ubuntu 的預設環境。過程中碰到的幾個重點:
startx
會去找.xinitrc
, 沒有的話就用/etc/X11/xinit/xinitrc
, 裡面內容是:1
2
3
4
5
6
7
8
# /etc/X11/xinit/xinitrc
#
# global xinitrc file, used by all X sessions started by xinit (startx)
# invoke global X session script
. /etc/X11/Xsession也就是說看
/etc/X11/{Xsession,Xsession.d/}
就可理解整個流程。這跟之前寫的 gnome-keyring-daemon 搭配 openssh 裡面直接新增一個 desktop 檔去執行 Xsession 很類似,allow-user-xsession
有開的話,最後就會去跑~/.xsession
, 裡面做好準備然後直接執行 awesome / i3 之類的就可以了。差異是沒有透過 gdm 之類的 display manager, 環境很好控制,就是命令列的環境再疊加上去。除錯看~/.xsession-errors
.但也是因為沒通過 display manager,
gnome-keyring-daemon
不會被 pam 叫起來,這點可以直接去改/etc/pam.d/login
, 加上兩行:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21--- login 2025-07-25 04:40:41.250611143 +0800
+++ /etc/pam.d/login 2025-07-25 04:03:32.288134460 +0800
# Standard Un*x authentication.
@include common-auth
+# for startx
+auth optional pam_gnome_keyring.so
+
# This allows certain extra groups to be granted to a user
# based on things like time of day, tty, service, and user.
# Please edit /etc/security/group.conf to fit your needs
# Standard Un*x account and session
@include common-account
@include common-session
+
+# for startx
+session optional pam_gnome_keyring.so auto_start
+
@include common-password如此在登入之後 gnome-keyring-daemon 一樣會是在
/usr/bin/gnome-keyring-daemon --daemonize --login
的狀態,這時只要在.xsession
這樣執行 i3:1
2
3
4
5
6
eval `gnome-keyring-daemon -s`
export SSH_AUTH_SOCK
exec i3ssh 及 chrome 要用的 keyring 之類就都很正常了。
輸入法我用 fcitx5,
im-config -n fcitx5
會產生~/.xinputrc
, 然後/etc/X11/Xsession.d/70im-config_launch
會去執行。如果有問題就從這裡開始追。可以在.xinputrc
最前面加上IM_CONFIG_VERBOSE=true
產生詳細訊息。
截至目前為止對 i3 算是滿意,麻煩的是這些 distro 環境設定,i3 作為 window manager 本身是很簡單的。