river
river 是一个基于 wlroots 的 Wayland 动态平铺合成器,其灵感来源于 dwm、xmonad 和 bspwm,但并非基于它们。其配置通过一个外部可执行文件完成。
其声明的设计目标是:
- 简单且可预测的行为,river 应该易于使用且认知负荷低。
- 基于视图堆栈和标签的窗口管理。
- 由用户编写的外部可执行文件生成的动态布局。提供了默认的 rivertile 布局生成器。
- 通过自定义 Wayland 协议和实现该协议的独立 riverctl 二进制文件进行脚本化配置和控制。
安装
启动
一个单一的可执行文件用作配置文件。默认情况下,不会为用户设置初始化文件,因此在创建 init 文件之前,不会有任何键绑定或默认应用程序可用。请注意,这包括退出键绑定,因此在运行 river 之前,请在 tty 或另一个桌面环境中进行设置。
可以在 /usr/share/river/example/ 中找到示例配置 init 文件。将其复制为 ~/.config/river/init 并确保它是 可执行的。
手动设置
输入 river(退出到 tty,用户仍登录)或 exec river(更安全地退出到 tty,用户注销)。
从 TTY
River 可以通过类似 startx 的方式自动启动,方法是在 .bash_profile 或其他 shell 的等效文件中设置环境变量检查。参见 Xinit#Autostart X at login,将 $DISPLAY 替换为 $WAYLAND_DISPLAY,并运行 exec river。
显示管理器
River 不官方支持显示管理器,但许多显示管理器无需或只需少量努力即可工作。一个会话条目默认安装在 /usr/share/wayland-sessions/ 中。
配置
配置文件可以是 shell 脚本或可执行程序,包含一系列 riverctl 命令,用于定义键绑定、输入设置和窗口规则。它在启动时执行一次,但可以像任何其他 shell 脚本一样重新运行(考虑重复任何自动启动的派生操作的影响)。每个设置也可以通过在终端中运行相关的 riverctl 行来单独运行。这允许临时覆盖 init 设置、动态更新和测试新设置。
例如,将快捷键 Super+PrtSc 映射到使用 grim 应用程序截屏并显示一个临时的 桌面通知。
riverctl map normal Super Print spawn "grim && notify-send -t 2000 'Screenshot taken'"
spawn 命令可以启动任何应用程序或脚本,但期望单个单词参数。较长的表达式需要用引号括起来。
键盘布局
riverctl keyboard-layout gb
可以输入多个布局,以逗号分隔的列表形式,例如 gb,fr。
变量和其他 shell 结构可以使用:mod='Mod4'、set term foot 等,取决于你的 shell。
触摸板示例
提供了一些触摸板行为和焦点偏好设置。
riverctl input pointer-2-7-SynPS/2_Synaptics_TouchPad tap enabled riverctl focus-follows-cursor normal
可以使用以下命令识别用于这些设置的确切键盘、鼠标和触摸板型号:
riverctl list-inputs
窗口规则
有时希望将某些窗口默认设置为非平铺。可以通过类或标题定义浮动窗口。
riverctl rule-add -app-id 'galculator' float riverctl rule-add -app-id 'thunar' float # make all Thunar windows floating riverctl rule-add -app-id 'thunar' -title '* - Thunar' no-float # except main window
用法
自启动
使用 riverctl spawn 而不带键绑定,可以在启动时运行任何可执行文件,例如:
riverctl spawn "i3-battery-popup -n -m 'Battery Low!'"
技巧与提示
暂存区
River 默认不定义任何暂存区,但可以在默认的 0-9 之外的任何标签上进行设置。首先,定义标签号,然后定义移动应用程序到暂存区标签并切换其显示的键映射,最后,阻止新窗口被分配到暂存区。
scratch_tag=$((1 << 20 ))
riverctl map normal Super P toggle-focused-tags ${scratch_tag} # toggle the scratchpad
riverctl map normal Super+Shift P set-view-tags ${scratch_tag} # send windows to the scratchpad
# Set spawn tagmask to ensure new windows do not have the scratchpad tag unless explicitly set.
all_but_scratch_tag=$(( ((1 << 32) - 1) ^ $scratch_tag ))
riverctl spawn-tagmask ${all_but_scratch_tag}
模式
River 支持键映射模式,允许重用映射,并组合更少的按键。有两种默认模式:“normal”和“locked”(定义屏幕锁定时的允许的键映射)。可以添加自定义模式。例如,如果浮动窗口很少使用,操纵这些窗口的键映射可以在“float”模式下定义。模式的进入和退出键映射分别设置为第一个和最后一个映射,其他映射在它们之间。
riverctl declare-mode float
riverctl map normal Super R enter-mode float # Super+R to enter float mode
### Floating window mappings but note that these also apply to tiled windows.
#
# Super {Arrows} to move views
riverctl map float Super Left move left 100
riverctl map float Super Down move down 100
riverctl map float Super Up move up 100
riverctl map float Super Right move right 100
# Alt+{arrows} to snap views to screen edges
riverctl map float Alt Left snap left
riverctl map float Alt Down snap down
riverctl map float Alt Up snap up
riverctl map float Alt Right snap right
# Shift+{arrows} to resize views
riverctl map float Shift Left resize horizontal -100
riverctl map float Shift Down resize vertical 100
riverctl map float Shift Up resize vertical -100
riverctl map float Shift Right resize horizontal 100
riverctl map float None Escape enter-mode normal # Escape to exit float mode and return to normal mode
请注意,浮动窗口修饰符也适用于平铺窗口,使它们浮动并可能导致不可预测的布局。
外部工具
与其他许多 Wayland 极简平铺客户端一样,不包含其他工具。示例外部栏、截屏工具、启动器等列在 River wiki 中,包括一些具有 River 特有功能的工具。
故障排除
屏幕录制
如果屏幕录制在 river 中不起作用,请检查 systemd 是否正确设置了所需的 环境变量。
$ systemctl --user show-environment
你应该会发现类似这样的内容:
WAYLAND_DISPLAY=wayland-1 XDG_CURRENT_DESKTOP=river
如果这些变量中的任何一个未设置,你可以在你的 .config/river/init 中添加此内容:
systemctl --user import-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=river systemctl --user restart xdg-desktop-portal
如果需要进一步的故障排除,请尝试:
- 确保 XDG Desktop Portal 服务正在运行。
$ systemctl --user status xdg-desktop-portal.service $ systemctl --user status xdg-desktop-portal-wlr.service
- 停止
xdg-desktop-portal.service并手动运行它,看看是否有效。
$ systemctl --user stop xdg-desktop-portal $ XDG_CURRENT_DESKTOP=river /usr/lib/xdg-desktop-portal
- 使用 Mozilla WebRTC 测试进行测试。
与你在互联网上找到的旧帖子可能不同,不再需要安装 pipewire-media-session,因为 wireplumber 现在工作正常。
参见
- River Codeberg 仓库
- River wiki
- 开发者设置博客文章[死链接 2025-11-17—SSL 错误]