Jump to content

Sway: Difference between revisions

601 bytes added ,  30 May 2022
Alternatives to autostart Sway
imported>Rasmus-kirk
No edit summary
imported>Onny
(Alternatives to autostart Sway)
Line 104: Line 104:


=== Autostart Sway ===
=== Autostart Sway ===
Add the following lines to autostart sway after user login:
It is possible to use greetd, a minimal login manager, to autostart Sway:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
   environment.loginShellInit = ''
services.greetd = {
    if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
  enable = true;
      exec sway
   settings = rec {
    fi
    initial_session = {
  '';
      command = "${pkgs.sway}/bin/sway";
      user = "myuser";
    };
    default_session = initial_session;
  };
};
</nowiki>}}
 
Where <code>myuser</code> needs to be replaced with the username which should execute Sway.
 
Alternatively,  you could use <code>getty</code> to auto login into <code>tty1</code> with <code>myuser</code>. Using <code>loginShellInit</code> Sway will automatically get started after user login:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
services.getty.autologinUser = "myuser";
 
environment.loginShellInit = ''
  if [ -z $DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
    exec sway
  fi
'';
</nowiki>}}
</nowiki>}}


Anonymous user