跳转至内容

river-classic

来自 ArchWiki

river-classic 是一个基于 wlroots 的 Wayland 动态平铺合成器,其灵感来自 dwm、xmonad 和 bspwm,但并非基于它们。配置通过一个外部可执行文件完成。它是现在非单体式合成器 river 的旧分支。

其声明的设计目标是:

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

安装

river-classic 通过 river-classic 软件包安装

启动

单个可执行文件被用作配置文件。默认情况下,系统不会为用户设置初始化文件,因此在创建初始化文件之前,无法使用任何快捷键或默认应用程序。请注意,这包括退出快捷键,因此在运行 river 之前,请在 tty 或另一个桌面环境中完成设置。

/usr/share/river/example/ 中提供了一个配置初始化文件示例。将其复制为 ~/.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 行来单独执行。这允许临时覆盖初始化设置、进行动态更新和测试新设置。

例如,要将快捷键 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

窗口规则

有时需要将某些窗口默认设置为非平铺。可以通过类名(class)或标题(title)来定义浮动窗口。

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!'"

技巧与提示

暂存窗 (Scratchpads)

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 不包含其他工具。示例外部状态栏、截图工具、启动器等列在 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

如果你需要进一步的故障排除,请尝试:

$ 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 现在运行良好。

参见

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.