0%

Arch从零配置GUI环境

先随便列一下,有空再填坑

arch安装

dhcpcd,sudo,nvim,
nvim alias as vim/vi
sudo alias 'sudo '

Xorg安装

基本无需配置,只要写.xinitrc就行了,参考Arch Wiki 关于xinitrc的介绍

注意先复制系统xinitrc,在其基础上修改,如果非要自己写,至少要记得source /etc/X11/xinit/xinitrc.d/中的脚本

xorg-xserver,xorg-uitls,xorg-initx

i3安装以及默认启动

https://wiki.archlinux.org/index.php/I3
https://wiki.archlinux.org/index.php/Autostarting

这个其实没啥问题,不过后面的东西都是由于i3太过简单而必须自己配置

联网问题

dhcpcd -> NetworkManager,network-manager-applet

输入法问题

https://wiki.archlinux.org/index.php/IBus
ibus,rime

多屏显示设置

xrandr

使用 alsa-utlls 进行声音输入输出设备管理

https://wiki.archlinux.org/index.php/Advanced_Linux_Sound_Architecture#Installation

alsamixer,amixer

安装虚拟终端 termite

bash自动补全、智能提示

bash-completion软件包

使用 thunar 进行文件管理

https://wiki.archlinux.org/index.php/File_manager_functionality#Overview
https://wiki.archlinux.org/index.php/thunar
https://wiki.archlinux.org/index.php/Udisks

需要关注 gvfs 系列软件包,还有 udisks2,它提供的udiskctl可以将设备挂载到 /run/media/$USERNAME的子目录中,可能ubuntu上所做的自动挂载也跟它有关系

使用 polkit 解决GUI中的权限问题

https://wiki.archlinux.org/index.php/Polkit

比如 thunar中磁盘挂载时可能需要授权,gparted的启动需要授权

相要使用它在GUI中授权还需要一个前端软件配合完成授权,我选择的是 lxsession 软件包,安装之后还需要设置使 lxpolkit 自启动,可以写在i3配置文件中。

GNOME Keyring

参考资料

https://wiki.archlinux.org/index.php/GNOME/Keyring

起因是这个
keyring

Troubleshooting Guide页面为:https://code.visualstudio.com/docs/editor/settings-sync#_troubleshooting-keychain-issues

之前犯的愚蠢错误

GUI界面叫seahorse,现在按照文档配置了一下,似乎vscode还会报错,但seahorse可以打开

改用了 PAM 方法似乎还是不行呀

现在可以了,记录下全过程

componet是启动之后就没改过,下面说的只是gnome-keyring的配置

  1. 只配.xinitrc,结果无效
  2. 只配PAM,无效
  3. PAM和.xinitrc都配,无效
  4. 配PAM,并在.xinitrc 中 source /etc/X11/xinit/xinitrc.d/50-systemd-user.sh,这次奇迹般的可以了,参考
    https://unix.stackexchange.com/questions/265503/how-do-i-fix-no-such-secret-collection-at-path-for-gnome-keyring-and-arch-l
  5. 只source,不配PAM可以吗?

破案了!!!

之前所说的一切错误都源自不规范定义的.xinitrc,正确的做法是先复制默认的配置,然后在默认配置基础上更改其行为,至少要保证source /etc/X11/xinit/xinitrc.d/ 中的脚本。

这些脚本有些是应用定义的关键脚本,如果不执行的话,可能会导致应用行为不正常。而我原先的.xinitrc是自己写的,没有source /etc/X11/xinit/xinitrc.d/ 中的脚本,出错也就不奇怪了,而默认的/etc/X11/xinit/xinitrc中就执行了类似的重要操作,在这个基础上修改就可以了

参考Arch Wiki 关于xinitrc的介绍

其中可能涉及一个关键脚本

1
2
3
4
5
6
7
8
9
[lpy@lpyarch ~]$ cat /etc/X11/xinit/xinitrc.d/50-systemd-user.sh 
#!/bin/sh

systemctl --user import-environment DISPLAY XAUTHORITY

if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY
fi
[lpy@lpyarch ~]$

/etc/X11/xinit/xinitrc.d/50-systemd-user.sh 会为用户级的systemd导入两个变量 DISPLAYXAUTHORITY,据说十分重要。

参考这篇文章 https://wiki.archlinux.org/index.php/systemd/User#DISPLAY_and_XAUTHORITY

1
DISPLAY is used by any X application to know which display to use and XAUTHORITY to provide a path to the user's .Xauthority file and thus the cookie needed to access the X server. If you plan on launching X applications from systemd units, these variables need to be set. Systemd provides a script in /etc/X11/xinit/xinitrc.d/50-systemd-user.sh to import those variables into the systemd user session on X launch. [3] So unless you start X in a nonstandard way, user services should be aware of the DISPLAY and XAUTHORITY

进一步分析

如果不source那个脚本,启动后会无法在seahorse中ublock,一个推测是,有运行在daemon的程序尝试让我输入密码来解锁,但它不知道DISPLAY和XAUTH,所以无法解锁

相关日志如下

1
2
3
4
5
6
7
8
9
10
11
12
Jan 02 18:56:45 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Activating service name='org.gnome.keyring.SystemPrompter' requested by ':1.34' (uid=1000 pid=404 comm="/usr/bin/gnome-keyring-daemon --daemonize --login ")
Jan 02 18:56:45 lpyarch org.gnome.keyring.SystemPrompter[1890]: Unable to init server: Could not connect: Connection refused
Jan 02 18:56:45 lpyarch gcr-prompter[1890]: cannot open display:
Jan 02 18:56:45 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Activated service 'org.gnome.keyring.SystemPrompter' failed: Process org.gnome.keyring.SystemPrompter exited with status 1
Jan 02 18:56:45 lpyarch gnome-keyring-daemon[404]: couldn't create system prompt: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.keyring.SystemPrompter exited with status 1


Jan 02 18:57:15 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Activating service name='org.gnome.keyring.SystemPrompter' requested by ':1.34' (uid=1000 pid=404 comm="/usr/bin/gnome-keyring-daemon --daemonize --login ")
Jan 02 18:57:16 lpyarch org.gnome.keyring.SystemPrompter[1899]: Unable to init server: Could not connect: Connection refused
Jan 02 18:57:16 lpyarch gcr-prompter[1899]: cannot open display:
Jan 02 18:57:16 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Activated service 'org.gnome.keyring.SystemPrompter' failed: Process org.gnome.keyring.SystemPrompter exited with status 1
Jan 02 18:57:16 lpyarch gnome-keyring-daemon[404]: couldn't create system prompt: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.keyring.SystemPrompter exited with status 1

经过分析,可能的原因是:
相关应用通过dbus,请求keyring进行密码验证,但是kering运行在systemd中,这时候由于没有执行上述/etc/X11/xinit/xinitrc.d/50-systemd-user.sh, daemon中没有 XAUTHORITYDISPLAY,keyring也就无法得知应该在哪里显示验证界面,所需授权文件又是哪个,故无法完成授权操作。

那么,在遇到这个问题的通过命令行systemd和dbus设置环境变量理应也可以解决这个问题,下面就来实际操作一下。

执行如下命令,再次去尝试unlock

1
2
systemctl --user import-environment DISPLAY XAUTHORITY
dbus-update-activation-environment DISPLAY XAUTHORITY

这一次执行日志如下,可以看到最后的信息已经表明解锁成功了,当然在GUI里面也能看到效果,这一次成功弹出了请求密码的界面。

我实际操作时,先故意输入了错误的密码,又一次输入了正确的密码,所以日志里有错误相关的信息也不奇怪

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Jan 02 19:45:17 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Activating service name='org.gnome.keyring.SystemPrompter' requested by ':1.34' (uid=1000 pid=404 comm="/usr/bin/gnome-keyring-daemon --daemonize --login ")
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: bus acquired: org.gnome.keyring.SystemPrompter
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: registering prompter
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: bus acquired: org.gnome.keyring.PrivatePrompter
Jan 02 19:45:17 lpyarch dbus-daemon[474]: [session uid=1000 pid=474] Successfully activated service 'org.gnome.keyring.SystemPrompter'
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: acquired name: org.gnome.keyring.SystemPrompter
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: received BeginPrompting call from callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: preparing a prompt for callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: creating new GcrPromptDialog prompt
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: GLib-GIO: _g_io_module_get_default: Found default implementation gvfs (GDaemonVfs) for ‘gio-vfs’
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: automatically selecting secret exchange protocol
Jan 02 19:45:17 lpyarch gcr-prompter[3670]: Gcr: generating public key
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: beginning the secret exchange: [sx-aes-1]\npublic=2G5a5ux0oDxyKtwTtKQeVK1Y8xiejwsV88063Ue4SCKhagOPRZcHCF+XKSNjn6Xb74zHTN222E3/a5RrNbGcS8VRmPTVGxxUc9mNBlWlgUg4MtBNtKF4t9DPBTC4RA4zw1ybsu20vXqyCm+z1OCmic+SmrpBqQzSYYRFn3633l/WirlYBmK/B/W0OFtuCZYJH39M46n/RJCC2PsyVI0WATBN8wyjnIGWjeC/X87qs8hrYPQTFQVpdDwSZ3sTvfkM\n
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: calling the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: acquired name: org.gnome.keyring.PrivatePrompter
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: returned from the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: received PerformPrompt call from callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: receiving secret exchange: [sx-aes-1]\npublic=DD1Zv/mXj0MFxWWAleJ1k8HlPzKHpAIsC3Xx8PNnEe0MhY17Nu4NXBNI9isZXxMY5yJXBQbFWXHe9oE2URrSwAMIkkd3I2Myb2jWTgRjH+oIFDonvPGJTKfojyUBkWEvyy3B5a17W5RanbZ3lf0BF3PgA1boQDBiFIXrXwWUQedUkrf8OUdYmlcLFMR5eUpJDDcllwP8qeNonWJI0zI8OeC+xMc71BWTxVHcx9P7ArL3nX4r5Ol5j4NNV/YGoyZ/\n
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: deriving shared transport key
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: deriving transport key
Jan 02 19:45:18 lpyarch gcr-prompter[3670]: Gcr: starting password prompt for callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: completed password prompt for callback :1.34@/org/gnome/keyring/Prompt/p56
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: encrypting data
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: sending the secret exchange: [sx-aes-1]\npublic=2G5a5ux0oDxyKtwTtKQeVK1Y8xiejwsV88063Ue4SCKhagOPRZcHCF+XKSNjn6Xb74zHTN222E3/a5RrNbGcS8VRmPTVGxxUc9mNBlWlgUg4MtBNtKF4t9DPBTC4RA4zw1ybsu20vXqyCm+z1OCmic+SmrpBqQzSYYRFn3633l/WirlYBmK/B/W0OFtuCZYJH39M46n/RJCC2PsyVI0WATBN8wyjnIGWjeC/X87qs8hrYPQTFQVpdDwSZ3sTvfkM\nsecret=YJvt3wtzr/dkfsZxg2nl1w==\niv=eTAIkduomuAKw163hVZkGQ==\n
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: calling the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: returned from the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: received PerformPrompt call from callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: receiving secret exchange: [sx-aes-1]\npublic=DD1Zv/mXj0MFxWWAleJ1k8HlPzKHpAIsC3Xx8PNnEe0MhY17Nu4NXBNI9isZXxMY5yJXBQbFWXHe9oE2URrSwAMIkkd3I2Myb2jWTgRjH+oIFDonvPGJTKfojyUBkWEvyy3B5a17W5RanbZ3lf0BF3PgA1boQDBiFIXrXwWUQedUkrf8OUdYmlcLFMR5eUpJDDcllwP8qeNonWJI0zI8OeC+xMc71BWTxVHcx9P7ArL3nX4r5Ol5j4NNV/YGoyZ/\n
Jan 02 19:45:31 lpyarch gcr-prompter[3670]: Gcr: starting password prompt for callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: completed password prompt for callback :1.34@/org/gnome/keyring/Prompt/p56
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: encrypting data
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: sending the secret exchange: [sx-aes-1]\npublic=2G5a5ux0oDxyKtwTtKQeVK1Y8xiejwsV88063Ue4SCKhagOPRZcHCF+XKSNjn6Xb74zHTN222E3/a5RrNbGcS8VRmPTVGxxUc9mNBlWlgUg4MtBNtKF4t9DPBTC4RA4zw1ybsu20vXqyCm+z1OCmic+SmrpBqQzSYYRFn3633l/WirlYBmK/B/W0OFtuCZYJH39M46n/RJCC2PsyVI0WATBN8wyjnIGWjeC/X87qs8hrYPQTFQVpdDwSZ3sTvfkM\nsecret=TOLxilfEWSSqacnL1hAEMw==\niv=uoSuwtbaJMNBvJt2sTdZpw==\n
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: calling the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: returned from the PromptReady method on /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: received PerformPrompt call from callback /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: stopping prompting for operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: closing the prompt
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: stopping prompting for operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: couldn't find the callback for prompting operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: stopping prompting for operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: couldn't find the callback for prompting operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: stopping prompting for operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: couldn't find the callback for prompting operation /org/gnome/keyring/Prompt/p56@:1.34
Jan 02 19:45:38 lpyarch gcr-prompter[3670]: Gcr: calling the PromptDone method on /org/gnome/keyring/Prompt/p56@:1.34, and ignoring reply
Jan 02 19:45:49 lpyarch gcr-prompter[3670]: Gcr: 10 second inactivity timeout, quitting
Jan 02 19:45:49 lpyarch gcr-prompter[3670]: Gcr: unregistering prompter
Jan 02 19:45:49 lpyarch gcr-prompter[3670]: Gcr: disposing prompter
Jan 02 19:45:49 lpyarch gcr-prompter[3670]: Gcr: finalizing prompter

至于为何在设置变量后就会自动授权而无需输入密码解锁,就是另一个问题了,可能跟设置的PAM有关。

锁屏

xsslock,i3lock,这个地方可能需要再好好了解一下系统的Session的概念和作用

https://rapiz.me/2019/lock-and-suspend/

壁纸