Sway: Difference between revisions
m nix->NixOS |
→Using greeter: fixing package path + formatting |
||
(8 intermediate revisions by 6 users not shown) | |||
Line 29: | Line 29: | ||
</syntaxhighlight>By default, the Sway module in NixOS comes with a set of extra packages, including the <code>foot</code> terminal, <code>swayidle</code>, <code>swaylock</code>, and <code>wmenu</code>, which can be configured under <code>[https://search.nixos.org/options?show=programs.sway.extraPackages programs.sway.extraPackages]</code> option. You may also want to include <code>wl-clipboard</code> for clipboard functionality and <code>slurp</code> for screenshot region selection. Additionally, for a more customizable bar implementation than <code>sway-bar</code>, <code>waybar</code> can be enabled with <code>programs.waybar.enable</code>. | </syntaxhighlight>By default, the Sway module in NixOS comes with a set of extra packages, including the <code>foot</code> terminal, <code>swayidle</code>, <code>swaylock</code>, and <code>wmenu</code>, which can be configured under <code>[https://search.nixos.org/options?show=programs.sway.extraPackages programs.sway.extraPackages]</code> option. You may also want to include <code>wl-clipboard</code> for clipboard functionality and <code>slurp</code> for screenshot region selection. Additionally, for a more customizable bar implementation than <code>sway-bar</code>, <code>waybar</code> can be enabled with <code>programs.waybar.enable</code>. | ||
The default Sway configuration is | The default Sway configuration is symlinked to <code>/etc/sway/config</code> and <code>/etc/sway/config.d/nixos.conf</code>. The latter file contains dbus and systemd configuration that is critical to using apps that depend on XDG desktop portals with Sway, and should be included in any custom configuration files. | ||
A few general comments: | A few general comments: | ||
Line 97: | Line 97: | ||
Tuigreet does not even need a separate compositor to launch. | Tuigreet does not even need a separate compositor to launch. | ||
{{file| | {{file|||<nowiki> | ||
services.greetd = { | services.greetd = { | ||
enable = true; | enable = true; | ||
settings = { | settings = { | ||
default_session = { | default_session = { | ||
command = "${pkgs | command = "${pkgs.tuigreet}/bin/tuigreet --time --cmd sway"; | ||
user = "greeter"; | user = "greeter"; | ||
}; | }; | ||
}; | }; | ||
}; | }; | ||
</nowiki>}} | </nowiki>|name=/etc/nixos/configuration.nix|lang=nix}} | ||
=== Automatic startup on boot === | |||
The snippet below will start Sway immediately on startup, without a greeter and '''without login prompt'''. Only consider using this in conjunction with [[Full Disk Encryption]]! | |||
<syntaxhighlight lang="nix"> | |||
services.getty = { | |||
autologinUser = "your_username"; | |||
autologinOnce = true; | |||
}; | |||
environment.loginShellInit = '' | |||
[[ "$(tty)" == /dev/tty1 ]] && sway | |||
''; | |||
</syntaxhighlight> | |||
== Configuration == | == Configuration == | ||
Line 113: | Line 126: | ||
=== Keyboard layout === | === Keyboard layout === | ||
Changing layout for all keyboards to German (de)<syntaxhighlight lang="console"> | Changing layout for all keyboards to German (de):<syntaxhighlight lang="console"> | ||
input * xkb_layout "de" | input * xkb_layout "de" | ||
</syntaxhighlight>The same thing accomplished in Home Manager:<syntaxhighlight lang="nix"> | |||
wayland.windowManager.sway.input."*".xkb_layout = "de"; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== High-DPI scaling === | === High-DPI scaling === | ||
Changing scale for all screens to factor 1.5<syntaxhighlight lang="console"> | Changing scale for all screens to factor 1.5:<syntaxhighlight lang="console"> | ||
output * scale 1.5 | output * scale 1.5 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 144: | Line 159: | ||
== Troubleshooting == | == Troubleshooting == | ||
=== Cursor is too tiny on HiDPI displays === | === Cursor is missing icons or too tiny on HiDPI displays === | ||
Using [[Home Manager]] try configuring a general mouse cursor size and theme. The reason that your cursor might be missing in some applications, is because <code>XCURSOR_THEME</code>is missing, which will cause applications relying on <code>XWAYLAND</code> to misbehave. Setting <code>sway.enable = true</code>, combined with the <code>name</code>, <code>package</code> and size will set the correct environment variables, which sway will then use. | |||
<syntaxhighlight lang="nix">home-manager.users.myUser = { | |||
home.pointerCursor = { | home.pointerCursor = { | ||
name = "Adwaita"; | name = "Adwaita"; | ||
package = pkgs | package = pkgs.adwaita-icon-theme; | ||
size = 24; | size = 24; | ||
x11 = { | x11 = { | ||
Line 160: | Line 172: | ||
defaultCursor = "Adwaita"; | defaultCursor = "Adwaita"; | ||
}; | }; | ||
sway.enable = true; | |||
}; | }; | ||
};</syntaxhighlight> | |||
}; | |||
</syntaxhighlight> | |||
Replace <code>myUser</code> with your user running the graphical environment. | Replace <code>myUser</code> with your user running the graphical environment. | ||
Line 216: | Line 227: | ||
When this happens on a new nixos system, enabling opengl in configuration.nix may fix this issue. | When this happens on a new nixos system, enabling opengl in configuration.nix may fix this issue. | ||
{{Note|<code>hardware.opengl</code> was renamed to <code>hardware.graphics</code> in NixOS 24.11.}} | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
hardware. | hardware.graphics.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||