river

来自 ArchWiki

river 是一个基于 wlroots 的 Wayland 动态平铺窗口管理器,灵感来源于 dwm、xmonad 和 bspwm,但并非基于它们。配置通过外部可执行文件进行。

其声明的设计目标是

  • 行为简单且可预测,river 应该易于使用且认知负荷低。
  • 基于视图和标签堆栈的窗口管理。
  • 动态布局由外部用户编写的可执行文件生成。 提供了一个默认的 rivertile 布局生成器。
  • 可通过自定义 Wayland 协议和单独的 riverctl 二进制文件实现可脚本化的配置和控制。

安装

River 可以通过 river 软件包或 AUR git 软件包 river-gitAUR 安装。

启动

单个可执行文件用作配置文件。 默认情况下,不会为用户设置初始化文件,因此在创建初始化文件之前,密钥绑定或默认应用程序不可用。 请注意,这包括退出密钥绑定,因此在运行 river 之前,请在 tty 或另一个桌面环境中进行设置。

示例配置初始化文件位于 /usr/share/river/example/ 中。 将其复制为 ~/.config/river/init 并确保它是可执行的

手动

输入 river(退出到 tty,用户仍然登录)或 exec river(更安全地退出到 tty,用户注销)

从 TTY

可以通过在 .bash_profile 或其他 shell 的等效文件中设置环境变量检查,以类似于 startx 的方式自动启动 River。 请参阅 Xinit#Autostart X at login,将 $DISPLAY 替换为 $WAYLAND_DISPLAY,然后运行 exec river

显示管理器

River 官方不支持显示管理器,但许多显示管理器无需或只需极少的工作即可使用。 会话条目默认安装在 /usr/share/wayland-sessions/ 中。

配置

配置文件可以是 shell 脚本或可执行程序,包含定义密钥绑定、输入设置和窗口规则的 riverctl 单个命令列表。 它在启动时执行一次,但可以像任何其他 shell 脚本一样重新运行(考虑复制任何自动启动的生成操作的效果)。 每个设置也可以通过简单地在终端中运行相关的 riverctl 行来单独运行。 这允许临时覆盖初始化设置、动态更新和测试新设置。

例如,要将快捷键 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 float-filter-add app-id 'galculator'
riverctl float-filter-add title 'File Operation Progress'

请注意,River 0.3 将引入新的 rule-add 设置,并且此语法将更改以适应这些更广泛的定义

riverctl rule-add -app-id 'galculator' float

用法

自动启动

使用 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
注意

与您在互联网上的旧帖子中可能找到的内容相反,没有必要安装 pipewire-media-session,因为 wireplumber 现在工作正常。

参见