Sway: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (9 intermediate revisions by 2 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 can work with an existing i3 configuration and supports most of i3's features, plus a few extras. | [https://swaywm.org/ 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. For users migrating from i3, see the [https://github.com/swaywm/sway/wiki/i3-Migration-Guide i3 migration guide]. | ||
[https://github.com/swaywm/sway/wiki/i3-Migration-Guide i3 migration guide] | |||
== Setup == | == Setup == | ||
| Line 11: | Line 10: | ||
{ | { | ||
environment.systemPackages = with pkgs; [ | environment.systemPackages = with pkgs; [ | ||
wl-clipboard # Copy/Paste functionality. | |||
mako # Notification utility. | |||
wl-clipboard # | |||
mako # | |||
]; | ]; | ||
# | # Enables Gnome Keyring to store secrets for applications. | ||
services.gnome.gnome-keyring.enable = true; | services.gnome.gnome-keyring.enable = true; | ||
# | # Enable Sway. | ||
programs.sway = { | programs.sway = { | ||
enable = true; | enable = true; | ||
| Line 63: | Line 59: | ||
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] | 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] | ||
=== Systemd services === | === Systemd services === | ||
| Line 130: | Line 119: | ||
wayland.windowManager.sway.systemd.variables = ["--all"]; | wayland.windowManager.sway.systemd.variables = ["--all"]; | ||
</nowiki>}} | </nowiki>}} | ||
=== Secret Service === | |||
It is recommended to enable a secret service provider such as [https://wiki.gnome.org/Projects/GnomeKeyring Gnome Keyring]. For more information on secret services check the [[Secret Service]] page. | |||
Install and enable: | |||
{{File|3=services.gnome.gnome-keyring.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}} | |||
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 = { | |||
greetd.enableGnomeKeyring = true; | |||
swaylock.enableGnomeKeyring = true; | |||
# If using a display manager such as GDM | |||
#gdm.enableGnomeKeyring = true; | |||
};|name=/etc/nixos/configuration.nix|lang=nix}} | |||
== Configuration == | == Configuration == | ||
| Line 181: | Line 184: | ||
};|name=/etc/nixos/home.nix|lang=nix}}For an on screen display for audio and brightness, check [[swayosd]]. | };|name=/etc/nixos/home.nix|lang=nix}}For an on screen display for audio and brightness, check [[swayosd]]. | ||
=== Touchpad === | === Input === | ||
==== 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 = | ||
| Line 358: | Line 363: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Screenshots === | |||
Screenshots using grim, slurp, and [https://github.com/XodTech/grimshot grimshot] for selection screenshots/full screen screenshots. | |||
Install tools | |||
{{File|3=environment.systemPackages = with pkgs; [ | |||
grim | |||
slurp | |||
sway-contrib.grimshot | |||
];|name=/etc/nixos/configuration.nix|lang=nix}} | |||
Example Home Manager configuration. | |||
{{File|3=wayland.windowManager.sway = { | |||
enable = true; | |||
config = let | |||
modifier = config.wayland.windowManager.sway.config.modifier; | |||
in { | |||
modifier = "Mod4"; | |||
keybindings = lib.mkOptionDefault { | |||
# Super + Shift + S | |||
# Screenshot a selection that saves to ~/Screenshots and copies to clipboard. | |||
"${modifier}+Shift+s" = "exec selection=$(slurp) && grim -g \"$selection\" - {{!}} tee ~/Screenshots/$(date +%Y-%m-%d_%H-%M-%S).png {{!}} wl-copy"; | |||
# Print Screen Button | |||
# Screenshot the currently focused screen, save to ~/Screenshots and copy to clipboard. | |||
"Print" = "exec grimshot save output - {{!}} tee ~/Screenshots/$(date +%Y-%m-%d_%H-%M-%S).png {{!}} wl-copy"; | |||
}; | |||
}; | |||
};|name=/etc/nixos/home.nix|lang=nix}} | |||
=== Screen sharing === | === Screen sharing === | ||
| Line 373: | Line 408: | ||
}; | }; | ||
}|name=/etc/nixos/configuration.nix|lang=nix}}{{Tip|Make sure that you do not have conflicting definitions for xdg.portal in Home Manager.}} | }|name=/etc/nixos/configuration.nix|lang=nix}}{{Tip|Make sure that you do not have conflicting definitions for xdg.portal in Home Manager.}} | ||
=== Auto mounting === | |||
==== USB storage devices (e.g. Flash Drives) ==== | |||
You can use [https://github.com/coldfix/udiskie udiskie] to automatically mount external storage medias. | |||
You will need to install and enable [https://www.freedesktop.org/wiki/Software/udisks/ udisks2]. | |||
{{File|3=services.udisks2.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}} | |||
Then, in Home Manager you can enable udiskie. | |||
{{File|3=services.udiskie.enable = true;|name=/etc/nixos/home.nix|lang=nix}} | |||
Udiskie will automatically mount attached USB storage media. | |||
See related info on [[USB storage devices]]. | |||
==== MTP (Android Phone Storage) ==== | |||
File managers that support [https://wiki.gnome.org/Projects/gvfs GVfs], such as [[Thunar]], can mount MTP devices using GVfs. See the page on [[MTP]] for related information. | |||
{{File|3=services.gvfs.enable = true;|name=/etc/nixos/configuration.nix|lang=nix}} | |||
=== SwayFX === | |||
[https://github.com/WillPower3309/swayfx SwayFX] is a fork of Sway that adds eye-candy effects, installing it is as simple as replacing your Sway package with SwayFX. Check the [[SwayFX]] page on the wiki for additional details. | |||
{{File|3=wayland.windowManager.sway = { | |||
enable = true; | |||
package = pkgs.swayfx; | |||
# Needed to build without errors. | |||
checkConfig = false; | |||
# SwayFX options must be configured through extraConfig. | |||
extraConfig = '' | |||
shadows enable | |||
corner_radius 11 | |||
blur_radius 7 | |||
blur_passes 2 | |||
''; | |||
};|name=/etc/nixos/home.nix|lang=nix}} | |||
=== Screen dimming with wl-gammarelay-rs === | === Screen dimming with wl-gammarelay-rs === | ||