Gentoo Firefox

我在重新部署 在MacBook Pro上安装Gentoo Linux 之后,一直思考如何将系统做到轻量级。在选择 在Gentoo环境安装和使用Sway 桌面之后,我同样考虑能够较好支持 wayland显示服务器协议 图形系统,并且较为轻量级的开源浏览器 Firefox:

  • 平衡Google这样 利维坦 的开源力量

  • 没有商业(广告)驱动,更专注于隐私,降低不必要的跟踪技术植入

安装

浏览器的编译非常庞大,不过 Firefox 编译似乎比 Gentoo Chromium 要轻很多,在我的 MacBook Air 13” Mid 2013 上一个晚上就完成了编译(具体时间不详),看起来我的 i5 处理器 8G 内存也能轻松完成

  • Firefox的 ebuild 有大量的USE参数,可以通过如下命令检查:

通过 equery 查询 www-client/firefox 的USE参数
equery uses www-client/firefox

输出信息:

通过 equery 查询 www-client/firefox 的USE参数输出案例
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for www-client/firefox-121.0:
 U I
 - - X                : Add support for X11
 + + clang            : Use Clang compiler instead of GCC
 + + dbus             : Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
...
 + + gmp-autoupdate   : Allow Gecko Media Plugins (binary blobs) to be automatically downloaded and kept up-to-date in user profiles
...
 + + jumbo-build      : Enable unified build - combines source files to speed up build process, but requires more memory
...
 + + system-av1       : Use the system-wide media-libs/dav1d and media-libs/libaom library instead of bundled
 + + system-harfbuzz  : Use the system-wide media-libs/harfbuzz and media-gfx/graphite2 instead of bundled
 + + system-icu       : Use the system-wide dev-libs/icu instead of bundled
 + + system-jpeg      : Use the system-wide media-libs/libjpeg-turbo instead of bundled
 + + system-libevent  : Use the system-wide dev-libs/libevent instead of bundled
 + + system-libvpx    : Use the system-wide media-libs/libvpx instead of bundled
...
 + + system-webp      : Use the system-wide media-libs/libwebp instead of bundled
 + + telemetry        : Send anonymized usage information to upstream so they can better understand our users
 + + wayland          : Enable dev-libs/wayland backend
...

需要注意,由于Firefox使用了 Rust Atlas 代码,所以天然的建议使用LLVM来最为编译后端,所以建议使用 Clang 而不是 GCC来完成编译。这里的USE参数默认有一个 clang 表示采用Clang完成软件编译。

wayland显示服务器协议 运行

备注

只要 wayland USE flag设置, www-client/firefoxwww-client/firefox-bin 默认就会激活 wayland ,这段应该不用设置。不过,如果在Wayland环境运行还是失败,可以尝试

从Firefox 65开始,就可以在 wayland显示服务器协议 环境中原生运行Firefox,只需要启动时带上 GDK_BACKEND=wayland 环境变量(当然 Gentoo emerge 时要配置 walyand USE flag):

在wayland环境运行firefox
GDK_BACKEND="wayland" firefox

此外,要确保通用Wayland环境变量,这样才能确保GDK和compositer通讯:

XDG_RUNTIME_DIR
WAYLAND_DISPLAY
XDG_SESSION_TYPE

要设置firefox始终使用Wayland后端,可以在 ~/.bashrc 中设置:

~/.bashrc 中设置 firefox 使用Wayland
# Enable Wayland support for Mozilla Firefox
export MOZ_ENABLE_WAYLAND=1

初步使用

  • 非常轻快,在 MacBook Air 13” Mid 2013 启动迅速(默认没有使用插件)

  • 默认就能够播放视频(B站),不过音频设置待完成

参考