{ config, pkgs, lib, keymap, isNvidiaGpu, ... }: with lib; let isQwerty = keymap == "us"; wlrRendererLine = if isNvidiaGpu then "export WLR_RENDERER=vulkan" else ""; monitorModule = types.submodule { options = { name = mkOption { type = types.str; }; resolution = mkOption { type = types.str; }; position = mkOption { type = types.str; }; defaultWorkspace = mkOption { type = types.int; }; }; }; desktopPackages = with pkgs; [ grim slurp wl-clipboard clipman wf-recorder font-awesome jetbrains-mono xdg-utils libnotify ] ++ ( if isNvidiaGpu then [ vulkan-validation-layers vulkan-headers vulkan-caps-viewer vulkan-extension-layer vulkan-tools ] else [ ] ); in { imports = [ ./swaylock.nix ./waybar.nix ./fuzzel.nix ./mako.nix ]; options = { my.desktop.sway = { enable = mkOption { type = types.bool; default = true; }; monitors = mkOption { type = types.listOf monitorModule; }; }; }; config = mkIf config.my.desktop.sway.enable { home.packages = desktopPackages; # Theming GTK gtk = { enable = true; theme = { name = "Nordic-darker"; package = pkgs.nordic; }; cursorTheme = { name = "Nordzy-cursors"; package = pkgs.nordzy-cursor-theme; }; iconTheme = { name = "Adwaita"; package = pkgs.adwaita-icon-theme; }; font = { name = "JetBrainsMono Nerd Font"; package = pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; }; }; }; qt = { enable = true; platformTheme.name = "gtk"; }; wayland.windowManager.sway = { enable = true; systemd.enable = false; package = null; checkConfig = false; config = rec { modifier = "Mod4"; left = "left"; right = "right"; up = "up"; down = "down"; terminal = "${pkgs.alacritty}/bin/alacritty"; menu = "${pkgs.fuzzel}/bin/fuzzel"; fonts = { names = [ "pango:JetBrainsMono Nerd Font Mono" ]; size = 11.0; }; input = { "*" = { xkb_layout = keymap; xkb_options = mkIf isQwerty "compose:ralt"; }; "12951:6519:ZSA_Technology_Labs_Voyager" = { xkb_layout = "us"; xkb_options = "compose:ralt"; }; "Synaptics TM3276-022" = { dwt = "enabled"; tap = "enabled"; natural_scroll = "enabled"; middle_emulation = "enabled"; }; }; seat = { "seat0" = { "xcursor_theme" = "Nordzy-cursors"; }; }; output = builtins.listToAttrs ( builtins.map (monitor: { name = monitor.name; value = { resolution = monitor.resolution; position = monitor.position; }; }) config.my.desktop.sway.monitors ) // { "*".bg = "/home/dala/Perso/wallpapers/tanuki.jpg fill"; }; workspaceOutputAssign = map (monitor: { output = monitor.name; workspace = builtins.toString monitor.defaultWorkspace; }) config.my.desktop.sway.monitors; startup = [ { command = '' ${pkgs.swayidle}/bin/swayidle -w \ timeout 1200 '${pkgs.swaylock}/bin/swaylock -f' \ timeout 1800 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \ before-sleep '${pkgs.swaylock}/bin/swaylock -f' ''; } { command = "exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK"; } { command = "${pkgs.nextcloud-client}/bin/nextcloud --background"; } { command = "${pkgs.keepassxc}/bin/keepassxc"; } { command = '' ${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${pkgs.clipman}/bin/clipman store --no-persist ''; } ]; modes = { resize = { "Left" = "resize shrink width 10px"; "Down" = "resize grow height 10px"; "Up" = "resize shrink height 10px"; "Right" = "resize grow width 10px"; "Return" = "mode default"; "Escape" = "mode default"; }; }; gaps = { inner = 5; smartGaps = true; }; floating = { modifier = "${modifier} normal"; }; bars = [ { command = "${pkgs.waybar}/bin/waybar"; } ]; keybindings = { "${modifier}+Return" = "exec ${terminal}"; "${modifier}+Shift+q" = "kill"; "${modifier}+d" = "exec ${menu}"; "${modifier}+Shift+r" = "reload"; "${modifier}+Shift+e" = "exec swaymsg exit"; "${modifier}+Shift+l" = "exec swaylock -f"; "${modifier}+Left" = "focus left"; "${modifier}+Down" = "focus down"; "${modifier}+Up" = "focus up"; "${modifier}+Right" = "focus right"; "${modifier}+Shift+Left" = "move left"; "${modifier}+Shift+Down" = "move down"; "${modifier}+Shift+Up" = "move up"; "${modifier}+Shift+Right" = "move right"; "${modifier}+1" = "workspace 1"; "${modifier}+2" = "workspace 2"; "${modifier}+3" = "workspace 3"; "${modifier}+4" = "workspace 4"; "${modifier}+5" = "workspace 5"; "${modifier}+6" = "workspace 6"; "${modifier}+7" = "workspace 7"; "${modifier}+8" = "workspace 8"; "${modifier}+9" = "workspace 9"; "${modifier}+0" = "workspace 10"; "${modifier}+ampersand" = "workspace 1"; "${modifier}+eacute" = "workspace 2"; "${modifier}+quotedbl" = "workspace 3"; "${modifier}+apostrophe" = "workspace 4"; "${modifier}+parenleft" = "workspace 5"; "${modifier}+minus" = "workspace 6"; "${modifier}+egrave" = "workspace 7"; "${modifier}+underscore" = "workspace 8"; "${modifier}+ccedilla" = "workspace 9"; "${modifier}+agrave" = "workspace 10"; "${modifier}+Shift+1" = "move container to workspace 1"; "${modifier}+Shift+2" = "move container to workspace 2"; "${modifier}+Shift+3" = "move container to workspace 3"; "${modifier}+Shift+4" = "move container to workspace 4"; "${modifier}+Shift+5" = "move container to workspace 5"; "${modifier}+Shift+6" = "move container to workspace 6"; "${modifier}+Shift+7" = "move container to workspace 7"; "${modifier}+Shift+8" = "move container to workspace 8"; "${modifier}+Shift+9" = "move container to workspace 9"; "${modifier}+Shift+0" = "move container to workspace 10"; "${modifier}+Shift+ampersand" = "move container to workspace 1"; "${modifier}+Shift+eacute" = "move container to workspace 2"; "${modifier}+Shift+quotedbl" = "move container to workspace 3"; "${modifier}+Shift+apostrophe" = "move container to workspace 4"; "${modifier}+Shift+parenleft" = "move container to workspace 5"; "${modifier}+Shift+minus" = "move container to workspace 6"; "${modifier}+Shift+egrave" = "move container to workspace 7"; "${modifier}+Shift+underscore" = "move container to workspace 8"; "${modifier}+Shift+ccedilla" = "move container to workspace 9"; "${modifier}+Shift+agrave" = "move container to workspace 10"; "${modifier}+h" = "splith"; "${modifier}+v" = "splitv"; "${modifier}+s" = "layout stacking"; "${modifier}+w" = "layout tabbed"; "${modifier}+e" = "layout toggle split"; "${modifier}+f" = "fullscreen"; "${modifier}+Shift+space" = "floating toggle"; "${modifier}+space" = "focus mode_toggle"; "${modifier}+a" = "focus parent"; "${modifier}+Shift+parenright" = "move scratchpad"; "${modifier}+parenright" = "scratchpad show"; "${modifier}+r" = "mode resize"; "XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; # increase sound volume "XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; # decrease sound volume "XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound "XF86MonBrightnessUp" = "exec --no-startup-id light -A 10"; "XF86MonBrightnessDown" = "exec --no-startup-id light -U 10"; "Control+XF86AudioMute" = "exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle"; "Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" -t png - | wl-copy --type image/png"; }; }; extraConfig = '' for_window [class=".*"] inhibit_idle fullscreen for_window [app_id=".*"] inhibit_idle fullscreen default_border pixel ''; xwayland = true; extraSessionCommands = '' export WLR_NO_HARDWARE_CURSORS=1 export XDG_CURRENT_DESKTOP=sway export _JAVA_AWT_WM_NONREPARENTING=1 export NIXOS_OZONE_WL=1 export QT_QPA_PLATFORM=wayland export QT_QPA_PLATFORMTHEME=qt5ct export QT_WAYLAND_DISABLE_WINDOWDECORATION=1 export MOZ_ENABLE_WAYLAND=1 export SDL_VIDEODRIVER=wayland ''; }; }; }