{ config, pkgs, lib, ... }: let display1 = "card0-eDP-1"; workspace1 = "1:Web"; workspace2 = "2:App"; workspace3 = "3:Chat"; workspace4 = "4:Read"; workspace5 = "5:Code"; workspace6 = "6:Password"; workspace7 = "7:Shell"; workspace8 = "8:Media"; cfg = config.homeModules.sway; in lib.mkIf cfg.enable { wayland.windowManager.sway = { enable = true; wrapperFeatures.gtk = true; config = rec { modifier = "Mod4"; # Windows key terminal = "alacritty"; menu = "bemenu-run"; startup = [ { command = "swaymsg workspace ${workspace5}; exec nvim"; } { command = "keepassxc"; } { command = "logseq"; } { command = "dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP XDG_SESSION_TYPE NIXOS_OZONE_WL XCURSOR_THEME XCURSOR_SIZE PATH"; } { command = "systemctl --user start sway-session.target"; } { command = "swaymsg workspace ${workspace7}; exec ${terminal}"; } ]; input = { "type:keyboard" = { xkb_layout = "de"; repeat_delay = "600"; repeat_rate = "25"; }; "type:pointer" = { natural_scroll = "false"; left_handed = "false"; middle_emulation = "true"; }; "*" = { xkb_layout = "de"; }; }; output = { "${display1}" = { res = "1920x1080"; pos = "0 0"; scale = "1"; }; "*" = { scale = "1"; }; }; keybindings = { # Launch terminal and menu "${modifier}+Return" = "exec ${terminal}"; "${modifier}+d" = "exec ${menu}"; # Kill focused window "${modifier}+Shift+q" = "kill"; # Reload and exit sway "${modifier}+Shift+c" = "reload"; "${modifier}+Shift+e" = "exec 'swaynag -t warning -m \"Exit Sway?\" -b \"Yes\" \"swaymsg exit\"'"; # Lock screen manually "${modifier}+l" = "exec swaylock"; # Screenshot tools "Print" = "exec grimshot save area"; "${modifier}+Shift+s" = "exec grimshot save window"; "${modifier}+s" = "exec grimshot save screen"; # Workspace switching "${modifier}+1" = "workspace ${workspace1}"; "${modifier}+2" = "workspace ${workspace2}"; "${modifier}+3" = "workspace ${workspace3}"; "${modifier}+4" = "workspace ${workspace4}"; "${modifier}+5" = "workspace ${workspace5}"; "${modifier}+6" = "workspace ${workspace6}"; "${modifier}+7" = "workspace ${workspace7}"; "${modifier}+8" = "workspace ${workspace8}"; # Move focused container to a workspace "${modifier}+Shift+1" = "move container to workspace ${workspace1}"; "${modifier}+Shift+2" = "move container to workspace ${workspace2}"; "${modifier}+Shift+3" = "move container to workspace ${workspace3}"; "${modifier}+Shift+4" = "move container to workspace ${workspace4}"; "${modifier}+Shift+5" = "move container to workspace ${workspace5}"; "${modifier}+Shift+6" = "move container to workspace ${workspace6}"; "${modifier}+Shift+7" = "move container to workspace ${workspace7}"; "${modifier}+Shift+8" = "move container to workspace ${workspace8}"; }; workspaceOutputAssign = [ { workspace = workspace1; output = display1; } ]; assigns = { "${workspace1}" = [ { app_id = "firefox"; } ]; "${workspace3}" = [ { class = "Signal"; } ]; "${workspace5}" = [ { class = "nvim"; } ]; "${workspace6}" = [ { app_id = "org.keepassxc.KeePassXC"; } ]; "${workspace7}" = [ { app_id = "Alacritty"; } ]; }; }; }; services.swayidle = { enable = true; timeouts = [ { timeout = 300; command = lib.getExe config.programs.swaylock.package; } ]; }; programs.swaylock = { enable = true; settings = { font = "JetBrainsMono Nerd Font"; screenshots = true; clock = true; show-failed-attempts = true; indicator-idle-visible = true; }; }; }