Sway: Difference between revisions
No longer called `gnome.adwaita-icon-theme`, moved to top level. |
mNo edit summary |
||
| (8 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
Sway is a tiling Wayland compositor and a drop-in replacement for the i3 window manager for X11. It | Sway is a tiling Wayland compositor and a drop-in replacement for the i3 window manager for X11. It can work with an existing i3 configuration and supports most of i3's features, plus a few extras. | ||
[https://github.com/swaywm/sway/wiki/i3-Migration-Guide i3 migration guide] | [https://github.com/swaywm/sway/wiki/i3-Migration-Guide i3 migration guide] | ||
| Line 7: | Line 7: | ||
=== Using NixOS === | === Using NixOS === | ||
Here is a minimal configuration: | Here is a minimal configuration: | ||
{ config, pkgs, lib, ... }: | {{File|3={ config, pkgs, lib, ... }: | ||
{ | { | ||
environment.systemPackages = with pkgs; [ | environment.systemPackages = with pkgs; [ | ||
| Line 26: | Line 26: | ||
wrapperFeatures.gtk = true; | wrapperFeatures.gtk = true; | ||
}; | }; | ||
} | }|name=/etc/nixos/configuration.nix|lang=nix}} | ||
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 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. | 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. | ||
| Line 42: | Line 43: | ||
Then you can enable Sway in your home manager configuration. Here is a minimal example: | Then you can enable Sway in your home manager configuration. Here is a minimal example: | ||
{{File|3=wayland.windowManager.sway = { | |||
enable = true; | enable = true; | ||
wrapperFeatures.gtk = true; # Fixes common issues with GTK 3 apps | wrapperFeatures.gtk = true; # Fixes common issues with GTK 3 apps | ||
| Line 55: | Line 56: | ||
]; | ]; | ||
}; | }; | ||
}; | };|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. | ||
You | You may need to activate dbus manually from .zshrc to use i.e: dunst, see [https://discourse.nixos.org/t/dunst-crashes-if-run-as-service/27671/2 Dunst crashes if run as service] | ||
{{Note| | {{Note| | ||
| 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>|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>When launched directly from the TTY sway won't inherit the user environment. This can 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 147: | Line 162: | ||
=== Cursor is missing icons or too tiny on HiDPI displays === | === Cursor is missing icons or too tiny on HiDPI displays === | ||
==== With programs.sway ==== | |||
<syntaxhighlight lang="nix> | |||
{ | |||
programs.sway.extraPackages = with pkgs; [ | |||
adwaita-icon-theme # mouse cursor and icons | |||
gnome-themes-extra # dark adwaita theme | |||
... | |||
]; | |||
} | |||
</syntaxhighlight> | |||
In ~/.config/sway/config | |||
<syntaxhighlight> | |||
seat "*" xcursor_theme Adwaita 32 | |||
</syntaxhighlight> | |||
==== With Home Manager ==== | |||
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. | 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. | ||
| Line 220: | Line 253: | ||
hardware.graphics.enable = true; | hardware.graphics.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Systemd user services missing environment variables (PATH, etc) === | |||
When sway is launched with out display manager systemd won't inherit the users environment variables. To fix this add the following to your home-manager configuration: | |||
{{File|3=wayland.windowManager.sway.systemd.variables = ["--all"];|name=home.nix|lang=nix}} | |||
=== Touchscreen input bound to the wrong monitor in multi-monitor setups === | === Touchscreen input bound to the wrong monitor in multi-monitor setups === | ||
| Line 279: | Line 316: | ||
}; | }; | ||
}; | }; | ||
</syntaxhighlight> | |||
=== Screen sharing with Firefox, Chromium === | |||
<syntaxhighlight lang="nix"> | |||
{ pkgs, ... }: | |||
{ | |||
# xdg portal + pipewire = screensharing | |||
xdg.portal = { | |||
enable = true; | |||
wlr.enable = true; | |||
}; | |||
services.pipewire = { | |||
enable = true; | |||
alsa.enable = true; | |||
pulse.enable = true; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
=== Screen dimming with wl-gammarelay-rs === | |||
Add <code>wl-gammarelay-rs</code> to programs.sway.extraPackages, then add the following to sway config: | |||
<syntaxhighlight> | |||
# start daemon | |||
exec wl-gammarelay-rs | |||
# bind shortcut to reset brightness | |||
bindsym $mod+Control+0 exec busctl --user set-property rs.wl-gammarelay / rs.wl.gammarelay Brightness d 1 | |||
# bind shortcut to dim screen for a particular output | |||
bindsym $mod+Control+Underscore exec busctl --user set-property rs.wl-gammarelay /outputs/DP_1 rs.wl.gammarelay Brightness d 0.5 | |||
</syntaxhighlight> | |||
=== Inhibit swayidle/suspend when fullscreen === | |||
Add to sway config: | |||
<syntaxhighlight> | |||
# When you use `for_window` the command you give is not executed | |||
# immediately. It is stored in a list and the command is executed | |||
# every time a window opens or changes (eg. title) in a way that | |||
# matches the criteria. | |||
# inhibit idle for fullscreen apps | |||
for_window [app_id="^.*"] inhibit_idle fullscreen | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Window managers]] | [[Category:Window managers]] | ||
[[Category:Applications]] | [[Category:Applications]] | ||