Sway: Difference between revisions
mNo edit summary |
style fixes |
||
| (One intermediate revision by one other user not shown) | |||
| Line 42: | Line 42: | ||
Then you may enable Sway in your Home Manager configuration. Here is a minimal example: | Then you may enable Sway in your Home Manager configuration. Here is a minimal example: | ||
{{File|3=wayland.windowManager.sway = { | {{File|3= | ||
wayland.windowManager.sway = { | |||
enable = true; | |||
wrapperFeatures.gtk = true; # Fixes common issues with GTK 3 apps | |||
config = rec { | |||
modifier = "Mod4"; | |||
# Use kitty as default terminal | |||
terminal = "kitty"; | |||
startup = [ | |||
# Launch Firefox on start | |||
{ command = "firefox"; } | |||
]; | |||
}; | |||
}; | |||
|name=/etc/nixos/home.nix|lang=nix}} | |||
See [https://nix-community.github.io/home-manager/options.xhtml#opt-wayland.windowManager.sway.enable Home Manager's Options for Sway] for a complete list of configuration options. | See [https://nix-community.github.io/home-manager/options.xhtml#opt-wayland.windowManager.sway.enable Home Manager's Options for Sway] for a complete list of configuration options. | ||
| Line 63: | Line 65: | ||
Kanshi is an output configuration daemon. As explained above, we don't run Sway itself as a systemd service. There are auxiliary daemons that we do want to run as systemd services, for example Kanshi [https://gitlab.freedesktop.org/emersion/kanshi], which implements monitor hot swapping. It would be enabled as follows: | Kanshi is an output configuration daemon. As explained above, we don't run Sway itself as a systemd service. There are auxiliary daemons that we do want to run as systemd services, for example Kanshi [https://gitlab.freedesktop.org/emersion/kanshi], which implements monitor hot swapping. It would be enabled as follows: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
# kanshi systemd service | |||
systemd.user.services.kanshi = { | |||
description = "kanshi daemon"; | |||
environment = { | |||
WAYLAND_DISPLAY="wayland-1"; | |||
DISPLAY = ":0"; | |||
}; | |||
serviceConfig = { | |||
Type = "simple"; | |||
ExecStart = ''${pkgs.kanshi}/bin/kanshi -c kanshi_config_file''; | |||
}; | }; | ||
}; | |||
</nowiki>}} | </nowiki>}} | ||
| Line 117: | Line 119: | ||
''; | ''; | ||
</syntaxhighlight>When launched directly from the TTY, Sway will not inherit the user environment. This may cause issues with systemd user services such as application launchers or [[Swayidle]]. To fix this, add the following to your Home Manager configuration:{{file|home.nix|nix|<nowiki> | </syntaxhighlight>When launched directly from the TTY, Sway will not inherit the user environment. This may cause issues with systemd user services such as application launchers or [[Swayidle]]. To fix this, add the following to your Home Manager configuration:{{file|home.nix|nix|<nowiki> | ||
wayland.windowManager.sway.systemd.variables = ["--all"]; | |||
</nowiki>}} | </nowiki>}} | ||
| Line 125: | Line 127: | ||
Install and enable: | Install and enable: | ||
{{File|3=services.gnome.gnome-keyring.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}} | {{File|3=services.gnome.gnome-keyring.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}} | ||
In order to unlock the keyring | In order to unlock the keyring through logins from greeters and screen locking utilities you will need to enable them through PAM. | ||
{{File|3=security.pam.services = { | {{File|3=security.pam.services = { | ||
greetd.enableGnomeKeyring = true; | greetd.enableGnomeKeyring = true; | ||
| Line 138: | Line 140: | ||
=== Keyboard layout === | === Keyboard layout === | ||
Changing layout for all keyboards to German (de):<syntaxhighlight | Changing layout for all keyboards to German (de): | ||
<syntaxhighlight> | |||
input * xkb_layout "de" | input * xkb_layout "de" | ||
</syntaxhighlight>The same thing accomplished in Home Manager:<syntaxhighlight lang="nix"> | </syntaxhighlight>The same thing accomplished in Home Manager:<syntaxhighlight lang="nix"> | ||
| Line 145: | Line 148: | ||
=== High-DPI scaling === | === High-DPI scaling === | ||
Changing scale for all screens to factor 1.5:<syntaxhighlight | Changing scale for all screens to factor 1.5:<syntaxhighlight> | ||
output * scale 1.5 | output * scale 1.5 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 188: | Line 191: | ||
==== Touchpad ==== | ==== Touchpad ==== | ||
See the [https://www.mankier.com/5/sway-input sway-input man page] for options. | See the [https://www.mankier.com/5/sway-input sway-input man page] for options. | ||
{{File|3=wayland.windowManager.sway = | {{File|3= | ||
wayland.windowManager.sway = { | |||
enable = true; | |||
config.input = { | |||
"type:touchpad" = { | |||
# Enables or disables tap for specified input device. | |||
tap = "enabled"; | |||
# Enables or disables natural (inverted) scrolling for the specified input device. | |||
natural_scroll = "enabled"; | |||
# Enables or disables disable-while-typing for the specified input device. | |||
dwt = "enabled"; | |||
}; | }; | ||
};|name=/etc/nixos/home.nix|lang=nix}} | }; | ||
}; | |||
|name=/etc/nixos/home.nix|lang=nix}} | |||
== Troubleshooting == | == Troubleshooting == | ||
| Line 226: | Line 230: | ||
{{File|3=home.pointerCursor = { | {{File|3=home.pointerCursor = { | ||
name = "Adwaita"; | |||
package = pkgs.adwaita-icon-theme; | |||
size = 24; | |||
x11 = { | |||
enable = true; | |||
defaultCursor = "Adwaita"; | |||
}; | |||
sway.enable = true; | |||
};|name=/etc/nixos/home.nix|lang=nix}} | };|name=/etc/nixos/home.nix|lang=nix}} | ||
| Line 243: | Line 246: | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
fonts = { | |||
packages = with pkgs; [ | |||
noto-fonts | |||
noto-fonts-cjk | |||
noto-fonts-emoji | |||
font-awesome | |||
source-han-sans | |||
source-han-sans-japanese | |||
source-han-serif-japanese | |||
]; | |||
fontconfig.defaultFonts = { | |||
serif = [ "Noto Serif" "Source Han Serif" ]; | |||
sansSerif = [ "Noto Sans" "Source Han Sans" ]; | |||
}; | }; | ||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 267: | Line 268: | ||
<syntaxhighlight lang="nix> | <syntaxhighlight lang="nix> | ||
security.pam.services.swaylock = {}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 304: | Line 305: | ||
Using [[Home Manager]] add the following to your Sway configuration: | Using [[Home Manager]] add the following to your Sway configuration: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
wayland.windowManager.sway = { | |||
[...] | |||
config = { | |||
[...] | |||
input = { | |||
[...] | |||
"type:touch" = { | |||
# Replace touchscreen_output_identifier with the identifier of your touchscreen. | |||
map_to_output = touchscreen_output_identifier; | |||
}; | |||
}; | |||
}; | |||
}; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 442: | Line 443: | ||
blur_passes 2 | blur_passes 2 | ||
''; | ''; | ||
};|name=/etc/nixos/home.nix|lang=nix}} | };|name=/etc/nixos/home.nix|lang=nix}} | ||
=== Screen dimming with wl-gammarelay-rs === | === Screen dimming with wl-gammarelay-rs === | ||
Add <code>wl-gammarelay-rs</code> to programs.sway.extraPackages, then add the following to sway config: | Add <code>wl-gammarelay-rs</code> to <code>programs.sway.extraPackages</code>, then add the following to sway config: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
# start daemon | # start daemon | ||