nwg-displays
本应用程序是 nwg-shell 项目的一部分。
Nwg-displays 是一个用于 sway、Hyprland 和 Niri Wayland 合成器的输出管理工具,灵感来自 wdisplays 和 wlay。该程序旨在:
- 提供一个直观的 GUI 来管理多个显示器;
- 应用设置;
- 将输出配置保存到文本文件;
- 将工作区 -> 输出分配保存到文本文件;
- 仅支持 sway、Hyprland 和 Niri。

安装
如果可能,请从您的 Linux 发行版软件仓库中安装。
否则,克隆此仓库并运行 install.sh 脚本。
依赖项
- gtk-layer-shell
- gtk3
- python
- python-gobject
- python-i3ipc
- python-build (make)
- python-installer (make)
- python-setuptools (make)
- python-wheel (make)
用法
$ nwg-displays -h
usage: nwg-displays [-h] [-m MONITORS_PATH] [-n NUM_WS] [-v]
options:
-h, --help show this help message and exit
-m MONITORS_PATH, --monitors_path MONITORS_PATH
path to save the monitors.conf file to, default: ~/.config/hypr/monitors.conf
-n NUM_WS, --num_ws NUM_WS
number of Workspaces in use, default: 10
-v, --version display version information
sway
保存到文件中的配置可轻松用于 sway 配置:
...
include ~/.config/sway/outputs
...
该程序还会保存 ~/.config/sway/workspaces 文件,该文件定义了工作区 -> 输出的关联。
workspace 1 output DP-1
workspace 2 output DP-1
workspace 3 output DP-1
workspace 4 output eDP-1
workspace 5 output eDP-1
workspace 6 output eDP-1
workspace 7 output HDMI-A-1
workspace 8 output HDMI-A-1
您可以将其包含在 sway 配置文件中,而无需手动编辑关联:
...
include ~/.config/sway/workspaces
...
如果你的输出名称在每次重启时都不同,请使用 --generic_names,例如当你使用 Thunderbolt 输出时。
如果你使用的 workspace 数量不是 8,请使用 --num_ws。
Hyprland
不要按照 Wiki 中描述的方式进行配置,而是插入以下这行:
source = ~/.config/hypr/monitors.conf
对于 0.55 及更高版本(使用 Lua),插入以下行:
require("monitors")
默认工作区 和 将工作区绑定到显示器:
插入:
source = ~/.config/hypr/workspaces.conf
对于 0.55 及更高版本,插入:
require("workspaces")
请勿在 Hyprland 设置中设置 disable_autoreload true,否则在应用更改后,您将不得不手动重新加载 Hyprland。
Niri
该程序会自动向您的 ~/.config/niri/config.kdl 文件中添加一个 include 指令:
include "monitor.kdl"
配置以 KDL 格式保存至 ~/.config/niri/monitor.kdl:
在 nwg-displays 中应用设置时,Niri 会自动重新加载配置。
注意: Niri 使用动态工作区,因此 Niri 不支持工作区分配功能。
设置
运行时配置文件位于您的配置目录中,例如 ~/.config/nwg-displays/config。
它是一个简单的 JSON 文件:
{
"view-scale": 0.15,
"snap-threshold": 10,
"indicator-timeout": 500
}
view-scale无需手动更改。GUI 会处理该事项。snap-threshold指定表示显示器的部件的刷新边距。我添加此值以防万一,因为我无法在高 DPI 显示器上测试这些内容。indicator-timeout确定用于识别屏幕的覆盖层应显示多长时间(以毫秒为单位)。设置为 0 可关闭覆盖层。