GNOME/指南
GNOME 是一个流行的能够启动 Xorg 和 Wayland 会话的 桌面环境 。本指南 尝试描述 GNOME 的所有方面,包括安装、配置和使用。
从 3.30 版本开始,Gentoo 上的 GNOME 能够再次在 OpenRC 上运行。[1]详情参见 无需systemd的GNOM。
什么是 GNOME?
项目
GNOME 项目是一个自由的软件组织,它致力于 GNOME 的发展,Unix/Linux 桌面套件和开发平台。 GNOME 基金会协调发展 GNOME 项目的其他方面。
软件
GNOME 是一个桌面环境和一个开发平台。这款自由软件是包括 Canonical (Ubuntu) 和 Red Hat(Red Hat Linux、Fedora、CentOS)在内的多个行业领导者的首选桌面。
社区
就像任何庞大的自由软件项目一样,GNOME有着广泛的用户和开发基地。GNOME Planet 是一个受GNOME黑客和贡献者欢迎的博客汇聚,而 developer.gnome.org 是给GNOME开发者看的。 GNOME Library 包含一个巨大的GNOME终端用户资源列表。
准备
从历史上看,Xorg 显示服务器是 Linux 上所有桌面环境的标准显示基础。对于 GNOME 3 及更高版本,已经开始转向更新的 Wayland 显示服务器协议。NVIDIA 以外的系统在 Wayland 上运行 GNOME 会话没有问题。
也就是说,退一步讲,最好先阅读并按照 Xorg Guide 中设置 X 环境的说明。
根据 GNOME 上游的说法,GNOME 40 是用 systemd 初始化系统编写的。因此,systemd 用户最好从 systemd 文章中阅读并遵守所有必要的内核设置。
安装
选择Profile
在安装 GNOME 套件之前,编辑系统的 USE 变量是个好主意。 Gentoo 开发人员提供了一个 GNOME 特定配置文件,以帮助对 GNOME 软件堆栈进行系统范围的调整。在安装 GNOME 之前选择最新且稳定的 GNOME 特定配置文件。
Read relevant documentation before performing any profile changes.
OpenRC
使用 logind 的 OpenRC 用户可以选择此特定配置文件:
root #
eselect profile set default/linux/amd64/17.1/desktop/gnome
systemd
systemd 用户将会选择以下 profile:
root #
eselect profile set default/linux/amd64/17.1/desktop/gnome/systemd
Make sure that X
, gtk
, and gnome
are in the USE variable located in /etc/portage/make.conf. It is recommended to enable support for D-Bus system-wide. systemd includes this system message bus.
USE="-qt5 -kde X gtk gnome systemd"
当使用
desktop/gnome
profile, 这些 USE flags将为你设置。 可以通过运行检查系统的profileeselect profile list. 可以作为root用户运行eselect profile set <profile-name> 修改。 一定要更改 "<profile-name>" 的数字或名称所需的 profile.Emerge
一旦完成,就由emerge GNOME来安装GNOME:
root #
emerge --ask gnome-base/gnome
“最小化”GNOME安装,emerge gnome-light,该选项提供了一个轻量级的GNOME安装没有额外的工具,但是安装一个完整的GNOME,它提供了所有你可能需要的额外的软件包。
root #
emerge --ask gnome-base/gnome-light
Also, consider disabling previewer for gnome-base/nautilus along with removing GNOME online accounts on low end devices to avoid net-libs/webkit-gtk and reduce build time:
gnome-base/nautilus -previewer
}}
{{{1}}}
这将需要一段时间,所以要开始阅读我们 wiki 中的其他部分。准备好了么?很好,现在更新环境变量:
root #
env-update && source /etc/profile
接下来剩余的服务和用户组将被清除。
验证 plugdev
组是否存在。如果是,建议让每个 GNOME 用户成为该组的成员,但这是可选的(该组不再常见)。
root #
getent group plugdev
plugdev:x:104:
取代 <username>
在接下来的命令与每一个GNOME用户的用户名:
root #
gpasswd -a <username> plugdev
第一印象
现在是时候看看什么是刚刚构建的。退出root 终端并以普通用户身份登录。下一步骤是配置会话管理器,使用GNOMEstartx 命令来调用(请看using startx 在Xorg guide的更多信息)。
启用 GDM
有关 GDM 故障排除的帮助可以在 GNOME/GDM 文章中找到。
OpenRC
For OpenRC systems, elogind is a dependency of GDM and must be started for GDM to run properly:
root #
rc-update add elogind boot
root #
rc-service elogind start
Next add display-manager-init to the default runlevel and start the service:
root #
emerge --ask --noreplace gui-libs/display-manager-init
In /etc/conf.d/display-manager set DISPLAYMANAGER to "gdm"
DISPLAYMANAGER="gdm"
To start on boot, add display-manager to the default runlevel:
root #
rc-update add display-manager default
To start GDM either reboot or start it with rc immediately:
root #
rc-service display-manager start
systemd
在引导时启动 GDM:
root #
systemctl enable gdm.service
要立即启动 GDM,运行:
root #
systemctl start gdm.service
以下命令同时启用并立即启动 GDM:
root #
systemctl enable --now gdm.service
另一个建议是激活 Network Manager,以防没有其他网络管理服务被激活。
使用 startx
Exit the root shell and log in as a regular user. The next step is to configure the session manager to run GNOME when the the startx command is invoked (see using startx in the Xorg guide for more information).
user $
echo "exec gnome-session" > ~/.xinitrc
从 gnome-base/gnome-session-2.26.2 开始,当使用 ~/.xinitrc 方法启动桌面时,用户需要预先添加 XDG_MENU_PREFIX 变量以获取 GNOME 菜单。如果 ~/.xinitrc 没有被使用,它将被自动处理;无需额外的配置。
user $
sed -i '1i\export XDG_MENU_PREFIX=gnome-' ~/.xinitrc
现在开始运行安装的图形环境startx:
user $
startx
如果一切顺利GNOME,我们高兴的问候您。祝贺你成功设置GNOME!
Privacy
Removing GNOME online accounts in the control center
Some users might be concerned about the fact that there is an online accounts section is the GNOME control center, which enables the user to connect the system to various services like Google, Microsoft, etc. In Portage, a USE flag can be set to remove this functionality:
USE="... -gnome-online-accounts"
This will tell Portage to not install the net-libs/gnome-online-accounts package if possible.
Re-emerge world with the --changed-use
flag and clean unused dependencies.
root #
emerge --ask --changed-use --update --deep @world
root #
emerge --depclean
Because of gnome-extra/gnome-contacts package being part of gnome-base/gnome via gnome-base/gnome-core-apps, the -gnome-online-accounts USE cannot be set as gnome-extra/gnome-contacts makes this a hard requirement to be enabled. gnome-base/gnome-light is an alternative though several other packages may be required for a full experience.
配置
Mixed localization
It could be general to have C
as the global default locale, with a different one for the desktop. This can be achieved by add settings:
LANG="zh_CN.utf8"
LC_MESSAGES="zh_CN.utf8"
LC_TIME="zh_CN.utf8"
Then choose the region for locale in gnome-setting-center, or via command:
user $
gsettings set org.gnome.system.locale region 'zh_CN.utf8'
With global locale default to
C
, only set the region is not likely to change the locale for desktop, for which, configuration in environment.d is necessary, especially the LC_MESSAGES variable. And to make it work for sure, the following packages may be necessary: ≥ sys-apps/systemd-249.6-r1 and ≥ gnome-base/gnome-40.0.Log out, make sure the old session is killed and re-login, these settings will be applied to the new session.
To override session's locale for terminal in gnome, add:
LANG="C.utf8"
LC_MESSAGES="C.utf8"
LC_TIME="C.utf8"
调整 GNOME
For extra configuration options in GNOME 40 install the gnome-extra/gnome-tweaks package. The tweak tool allows customization at a deeper level than the standard Settings frame.
Advanced tweaking
Advanced tweaking for GNOME can be performed from the command line via the gsettings or dconf commands or graphically via dconf-editor. All modifiable settings are accessible using these tools. For more information, see upstream's documentation.
GNOME 3 中的小部件
By default on Gentoo GNOME 40 does not support widgets. For users who wish to obtain widget functionality a separate package is available:
root #
emerge --ask gnome-extra/gnome-shell-extensions
安装 shell 扩展后,可以使用 eselect 来控制全局级别的默认值:
root #
eselect gnome-shell-extensions list
Available extensions (* means enabled for all users by default): [1] alternate-tab@gnome-shell-extensions.gcampax.github.com [2] apps-menu@gnome-shell-extensions.gcampax.github.com [3] auto-move-windows@gnome-shell-extensions.gcampax.github.com [4] drive-menu@gnome-shell-extensions.gcampax.github.com [5] launch-new-instance@gnome-shell-extensions.gcampax.github.com [6] native-window-placement@gnome-shell-extensions.gcampax.github.com [7] places-menu@gnome-shell-extensions.gcampax.github.com [8] screenshot-window-sizer@gnome-shell-extensions.gcampax.github.com [9] user-theme@gnome-shell-extensions.gcampax.github.com [10] window-list@gnome-shell-extensions.gcampax.github.com [11] windowsNavigator@gnome-shell-extensions.gcampax.github.com [12] workspace-indicator@gnome-shell-extensions.gcampax.github.com
通过网络浏览器启用点击安装 Shell 扩展
For web browsers such as Google Chrome, Chromium, and Vivaldi be sure to get the required browser add-on through the Chrome store: https://chrome.google.com/webstore/detail/gphhapmejobijbbhgpjhcjognlahblep
Firefox users can get it here: https://addons.mozilla.org/firefox/addon/gnome-shell-integration/
Opera users will have to snag it here: https://addons.opera.com/extensions/details/gnome-shell-integration/
After the add-on has been installed for the browser of choice, a backend must also be emerged:
root #
emerge --ask gnome-extra/gnome-browser-connector
It should now be possible to install, manage, and uninstall shell extensions at https://extensions.gnome.org/
If things are not working as expected check the upstream installation instructions for news.
Non-root user authentication for dialogs
Certain GNOME dialogs such as Printers, adding wireless networks, and Users require administrator authentication. This is handled through sys-auth/polkit and operates independently from app-admin/sudo. By default in Gentoo, the root account is the only administrator, and so even if a user account can run root commands through sudo, authentication in these GNOME dialogs will fail.
If you would like all users of the group wheel to be administrators, create a copy of /usr/share/polkit-1/rules.d/50-default.rules starting with a number lower than 50, and edit the line return ["unix-user:0"] to the following:
polkit.addAdminRule(function(action, subject) {
return ["unix-group:wheel"];
});
The Polkit page provides more details on rules configuration.
GNOME hotspot
In order for gnome-hotspot to work, the wireless card must support AP (access point) infrastructure mode. The following package USE flags are also needed:
net-misc/networkmanager connection-sharing
net-wireless/wpa_supplicant ap
此外,还需要以下内核选项:
Networking support (NET [=y])
Networking options --->
Network packet filtering framework (Netfilter) (NETFILTER [=y]) --->
IP: Netfilter Configuration --->
<*/M> IPv4 NAT (CONFIG_NF_NAT_IPv4)
<*/M> IPv4 masquerade support
<*/M> IP tables support (required for filtering/masq/NAT) (IP_NF_IPTABLES [=y])
<*/M> iptables NAT support
移除
卸载
A possible way to completely remove a GNOME installation is by explicitly uninstalling the gnome-base/gnome package, then cleaning the dependencies of that package.
为了做到这一点,请确保主 ebuild 存储库已同步:
root #
emerge --sync
接下来,运行全局更新使系统是全新的:
root #
emerge --ask --update --newuse --deep --with-bdeps=y @world
卸载 GNOME 基础包:
root #
emerge --ask --depclean gnome-base/gnome
最后,清理系统:
root #
emerge --ask --depclean
GNOME 现已删除。
故障排除
登录失败并显示消息 "Oh no something has gone wrong"
One source of this error can be the permissions for the video device. When logging in fails and a message appears that says "Oh no, something has gone wrong", then try to become a member of the video group. Add the user to the video group with gpasswd like so:
root #
gpasswd -a <user> video
Wayland 会话上的 GNOME 未与 NVIDIA 一起启动
Attempting to launch GNOME on Wayland sessions is a known issue. Unfortunately some older versions of the NVIDIA binary blob drivers are not compatible with Wayland. Systems that simply have older versions of the NVIDIA binary blob driver installed, but are not using it, can see this workaround.
For at least gnome-base/gdm-44.1
it is required to set NVreg_PreserveVideoMemoryAllocations=1
in /etc/modprobe.d/nvidia.conf
, otherwise Wayland support is being disabled.
GNOME built-in screen recorder is not working
GNOME's screen recorder uses vp8 codec which is developed by Google. The recorder needs this codec and pipewire screencast feature to record the desktop. It can be enabled it via the the vpx
and screencast
USE flags in either the make.conf or package.use files.
USE="vpx screencast"
GNOME and Pinentry not working with GPG
For example when using Evolution to sign emails with PGP, the private key needs to be decrypted. If this key has a password, a Pinentry dialogue trys to open. To enable the Gtk version, these configuration files need to be edited.
use-agent
pinentry-mode loopback
pinentry-program /usr/bin/pinentry-gnome3
外部资源
- https://github.com/dantrell/gentoo-project-gnome-without-systemd - 没有 systemd 的 GNOME
References
This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Lars Strojny,
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.