Niri/zh: Difference between revisions
Created page with "您可以使用 greeted 配置启动 niri:" Tags: Mobile edit Mobile web edit |
Created page with "Niri" Tags: Mobile edit Mobile web edit |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 36: | Line 36: | ||
== 配置 == | == 配置 == | ||
niri 的配置路径为 {{ic|$XDG_CONFIG_HOME/niri/config.kdl}}。因此,可以使用 [[Special:MyLanguage/Home Manager|Home Manager]] 进行配置: | |||
{{file|~/.config/home-manager/home.nix|nix|3= | {{file|~/.config/home-manager/home.nix|nix|3= | ||
| Line 44: | Line 42: | ||
}} | }} | ||
您可能想从[https://github.com/niri-wm/niri/blob/main/resources/default-config.kdl 默认配置文件]开始,如[https://github.com/niri-wm/niri/wiki/Getting-Started#main-default-hotkeys 这里]所述。 | |||
有关 niri 的配置选项,请参阅 [https://niri-wm.github.io/niri/ 此 wiki]。 | |||
=== Greetd === | === Greetd === | ||
| Line 79: | Line 73: | ||
== 额外设置 == | == 额外设置 == | ||
如[https://github.com/niri-wm/niri/wiki/Example-systemd-Setup 示例 systemd 设置 (niri wiki)]中所述,您可能需要设置一些额外的服务,包括以下的 [[Special:MyLanguage/Swayidle|Swayidle]]、[[Special:MyLanguage/Swaylock|Swaylock]]、[[Special:MyLanguage/Waybar|Waybar]]、[[Special:MyLanguage/Polkit|Polkit]] 和 [[Special:MyLanguage/Secret Service|Secret Service]],以补充常规窗口管理器的功能。其中一些设置也是启用[https://github.com/niri-wm/niri/blob/main/resources/default-config.kdl 默认配置文件]所有功能所必需的。 | |||
{{file|3= | {{file|3= | ||
| Line 92: | Line 84: | ||
|name=/etc/nixos/configuration.nix|lang=nix}} | |name=/etc/nixos/configuration.nix|lang=nix}} | ||
或者使用 [[Special:MyLanguage/Home Manager|Home Manager]]: | |||
{{file|~/.config/home-manager/home.nix|nix|3= | {{file|~/.config/home-manager/home.nix|nix|3= | ||
| Line 109: | Line 99: | ||
|name=~/.config/home-manager/home.nix|lang=nix}} | |name=~/.config/home-manager/home.nix|lang=nix}} | ||
< | <span id="Troubleshooting"></span> | ||
== | == 故障排除 == | ||
< | <span id="IME_not_working_on_Electron_apps"></span> | ||
=== IME | === IME 在 Electron 应用中无法正常工作 === | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 147: | Line 135: | ||
];}} | ];}} | ||
< | <span id="XWayland_apps_not_working"></span> | ||
=== XWayland | === XWayland 应用无法正常工作 === | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 171: | Line 158: | ||
</div> | </div> | ||
< | <span id="File_picker_not_working"></span> | ||
=== | === 文件选择器无法正常工作 === | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 187: | Line 173: | ||
};|name=/etc/nixos/configuration.nix|lang=nix}} | };|name=/etc/nixos/configuration.nix|lang=nix}} | ||
< | <span id="Waybar_launches_twice"></span> | ||
=== Waybar | === Waybar 启动两次 === | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> | ||
| Line 195: | Line 180: | ||
</div> | </div> | ||
< | <span id="See_Also"></span> | ||
== | == 另见 == | ||
* [[Special:MyLanguage/Wayland|Wayland]] | * [[Special:MyLanguage/Wayland|Wayland]] | ||
* [[Special:MyLanguage/Sway|Sway]] | * [[Special:MyLanguage/Sway|Sway]] | ||
* [[Special:MyLanguage/Wallpapers for Wayland| | * [[Special:MyLanguage/Wallpapers for Wayland|用于 Wayland 的壁纸]] | ||
* [https://github.com/sodiboo/niri-flake/ niri-flake] | * [https://github.com/sodiboo/niri-flake/ niri-flake] | ||
[[Category:Window managers]] | [[Category:Window managers]] | ||
[[Category:Applications{{#translation:}}]] | [[Category:Applications{{#translation:}}]] | ||
Latest revision as of 17:36, 31 May 2026
警告:显示标题“niri”覆盖了之前的显示标题“Niri”。
安装
只需启用 programs.niri:
programs.niri.enable = true;
niri-flake。
配置
niri 的配置路径为 $XDG_CONFIG_HOME/niri/config.kdl。因此,可以使用 Home Manager 进行配置:
xdg.configFile."niri/config.kdl".source = ./config.kdl;
有关 niri 的配置选项,请参阅 此 wiki。
Greetd
您可以使用 greeted 配置启动 niri:
programs.niri.enable = true;
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${config.programs.niri.package}/bin/niri-session";
user = "myuser";
};
};
};
# NixOS otherwise injects a stripped PATH via Environment= on the niri.service
# unit which shadows the imported user-manager PATH. Disabling the default
# lets niri inherit the full PATH set up by niri-session.
systemd.user.services.niri.enableDefaultPath = false;
额外设置
如示例 systemd 设置 (niri wiki)中所述,您可能需要设置一些额外的服务,包括以下的 Swayidle、Swaylock、Waybar、Polkit 和 Secret Service,以补充常规窗口管理器的功能。其中一些设置也是启用默认配置文件所有功能所必需的。
security.polkit.enable = true; # polkit
services.gnome.gnome-keyring.enable = true; # secret service
security.pam.services.swaylock = {};
programs.waybar.enable = true; # top bar
environment.systemPackages = with pkgs; [ alacritty fuzzel swaylock mako swayidle ];
或者使用 Home Manager:
programs.alacritty.enable = true; # Super+T in the default setting (terminal)
programs.fuzzel.enable = true; # Super+D in the default setting (app launcher)
programs.swaylock.enable = true; # Super+Alt+L in the default setting (screen locker)
programs.waybar.enable = true; # launch on startup in the default setting (bar)
services.mako.enable = true; # notification daemon
services.swayidle.enable = true; # idle management daemon
services.polkit-gnome.enable = true; # polkit
home.packages = with pkgs; [
swaybg # wallpaper
];
故障排除
IME 在 Electron 应用中无法正常工作
There is a general workaround to set NIXOS_OZONE_WL as described in Wayland#Electron_and_Chromium:
environment.sessionVariables.NIXOS_OZONE_WL = "1";
However, since niri does not support text-input-v1, sometimes enabling text-input-v3 by manually adding --wayland-text-input-version=3 flag is necessary for IME to work:
$ slack --wayland-text-input-version=3
wrapProgram may be used to add the flag automatically:
environment.systemPackages = [
(pkgs.symlinkJoin {
pname = pkgs.vscode.pname;
paths = [ pkgs.vscode ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/code --add-flags --wayland-text-input-version=3";
};)
];
XWayland 应用无法正常工作
There is a optional dependency for niri which is highly recommended to install (you can read this article to learn more about this)
environment.systemPackages = with pkgs; [
xwayland-satellite # xwayland support
];
Or using Home Manager
home.packages = with pkgs; [
xwayland-satellite # xwayland support
];
After you installed xwayland-satellite niri will integrate it out of the box and all of your XWayland apps will function properly.
文件选择器无法正常工作
If you are using xdg-desktop-portal-gnome, it will attempt to use Nautilus as the file picker, which will fail if Nautilus is not installed.
To work around this problem, you can force usage of the gtk or kde portals for file picker instead:
xdg.portal.config.niri = {
"org.freedesktop.impl.portal.FileChooser" = [ "gtk" ]; # or "kde"
};
Waybar 启动两次
When using a configuration option like programs.waybar.enable, waybar may launch twice on Niri. This is because the default Niri config file launches waybar on launch. Remove the spawn-at-startup "waybar" from the config file, or add waybar to your systems packages without using the home-manager option.