Sway: Difference between revisions

Systemd services: Original snippet does not allow kanshi to connect to the display
Axka (talk | contribs)
m nix->NixOS
 
(3 intermediate revisions by 2 users not shown)
Line 27: Line 27:
   };
   };
}
}
</syntaxhighlight>
</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 simlinked 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 34: Line 36:


=== Using Home Manager ===
=== Using Home Manager ===
To set up Sway using [[Home Manager]], first you must enable [[Polkit]] in your nix configuration:
To set up Sway using [[Home Manager]], first you must enable [[Polkit]] in your NixOS configuration:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
security.polkit.enable = true;
security.polkit.enable = true;
Line 43: Line 45:
   wayland.windowManager.sway = {
   wayland.windowManager.sway = {
     enable = true;
     enable = true;
    wrapperFeatures.gtk = true; # Fixes common issues with GTK 3 apps
     config = rec {
     config = rec {
       modifier = "Mod4";
       modifier = "Mod4";
Line 58: Line 61:


You might need to active 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 might need to active 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|
It's recommended to enable a [[Secret Service]] provider, like GNOME Keyring:
{{file|home.nix|nix|<nowiki>
services.gnome-keyring.enable = true;
</nowiki>}}
}}


=== Systemd services ===
=== Systemd services ===
Line 113: Line 123:


=== Brightness and volume ===
=== Brightness and volume ===
If you are on a laptop, you can set up brightness and volume function keys as follows:
You can set up brightness and volume function keys as follows by binding the key codes to their corresponding commands in your sway config. The following configurations accomplish this using <code>light</code> and <code>pulseaudio</code>:
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
users.users.yourusername.extraGroups = [ "video" ];
users.users.yourusername.extraGroups = [ "video" ];
Line 231: Line 241:
   };
   };
</syntaxhighlight>
</syntaxhighlight>
=== GTK apps take an exceptionally long time to start ===
This occurs because GTK apps make blocking calls to freedesktop portals to be displayed. If Sway is not integrated with dbus and systemd, it will not be able to communicate via the <code>org.freedesktop.portal.Desktop</code> portal. To fix this, see the [[Sway#Using NixOS|description]] of default Sway configurations earlier. Adding the following to your sway configuration, if it is not already present, may resolve the issue:
include /etc/sway/config.d/*
== Tips and tricks ==
== Tips and tricks ==