From 1f76671a71a3825bf981e06341927b42aecbb0f2 Mon Sep 17 00:00:00 2001 From: Alexander Wainwright Date: Sun, 21 Dec 2025 18:57:15 +1000 Subject: [PATCH] Refactor sway stuff --- alex/home.nix | 6 ++++ alex/sway.nix | 52 +++++++++++++++++++++++++++++++++++ hosts/count/configuration.nix | 1 + hosts/modules/desktop.nix | 36 ++---------------------- hosts/modules/sway.nix | 19 +++++++++++++ 5 files changed, 80 insertions(+), 34 deletions(-) create mode 100644 alex/sway.nix create mode 100644 hosts/modules/sway.nix diff --git a/alex/home.nix b/alex/home.nix index 1697b67..6e10cde 100644 --- a/alex/home.nix +++ b/alex/home.nix @@ -33,6 +33,12 @@ }; } else {}; + imports = [ + ] ++ (if isDesktop then [ + ./sway.nix + ] else []); + + home.shellAliases = { e = "ls -lh"; tree = "eza --tree"; diff --git a/alex/sway.nix b/alex/sway.nix new file mode 100644 index 0000000..d4c1c27 --- /dev/null +++ b/alex/sway.nix @@ -0,0 +1,52 @@ +{ pkgs, lib, ... }: { + wayland.windowManager.sway = { + enable = true; + config = { + modifier = "Mod4"; + terminal = "foot"; # Or your preferred terminal + menu = "wofi --show drun --allow-images"; + + input = { + "*" = { + xkb_layout = "us"; + xkb_variant = "dvorak"; + }; + }; + + bars = []; # Removes the duplicate default bar issue + + startup = [ + { command = "waybar"; } + ]; + + keybindings = let + modifier = "Mod4"; + in lib.mkOptionDefault { + "${modifier}+d" = "exec wofi --show drun --allow-images"; + "XF86AudioRaiseVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+"; + "XF86AudioLowerVolume" = "exec wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"; + "XF86AudioMute" = "exec wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; + "XF86MonBrightnessUp" = "exec light -A 5"; + "XF86MonBrightnessDown" = "exec light -U 5"; + }; + }; + }; + + programs.waybar = { + enable = true; + settings = { + mainBar = { + layer = "top"; + position = "top"; + modules-left = [ "sway/workspaces" ]; + modules-right = [ "pulseaudio" "clock" ]; + pulseaudio = { + format = "{volume}% {icon}"; + on-click = "pavucontrol"; + }; + }; + }; + }; + + programs.wofi.enable = true; +} diff --git a/hosts/count/configuration.nix b/hosts/count/configuration.nix index f81ecc3..83bc3c0 100644 --- a/hosts/count/configuration.nix +++ b/hosts/count/configuration.nix @@ -12,6 +12,7 @@ ../modules/desktop.nix ../modules/brother-printer.nix ../modules/home.nix + ../modules/sway.nix ]; # Bootloader. diff --git a/hosts/modules/desktop.nix b/hosts/modules/desktop.nix index 8930117..bdc48c9 100644 --- a/hosts/modules/desktop.nix +++ b/hosts/modules/desktop.nix @@ -7,40 +7,15 @@ layout = "us"; variant = "dvorak"; }; - - displayManager.gdm = { - enable = true; - wayland = true; - }; }; - # enable sway - programs.sway = { + services.displayManager.gdm = { enable = true; - wrapperFeatures.gtk = true; + wayland = true; }; - # 2. Inject the Dvorak config into /etc/sway/config.d/ - # The default Sway config automatically includes files in this folder. - environment.etc."sway/config.d/99-dvorak.conf".text = '' - input * { - xkb_layout "us" - xkb_variant "dvorak" - } - ''; - - - # Essential System Services for Sway - # (Sway doesn't autostart these like GNOME does, so you need them enabled - # system-wide) - security.polkit.enable = true; # For permission popups - services.gnome.gnome-keyring.enable = true; # For saving wifi/login passwords - services.desktopManager.gnome.enable = true; - # Enable the GNOME Desktop Environment. - services.displayManager.gdm.enable = true; - # enable japanese input i18n.inputMethod = { enable = true; @@ -68,13 +43,6 @@ bitwarden-desktop libreoffice-fresh - # sway stuff - grim # screenshot functionality - slurp # screenshot functionality - wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout - mako # notification system developed by swaywm maintainer - ]; - # Enable networking networking.networkmanager.enable = true; diff --git a/hosts/modules/sway.nix b/hosts/modules/sway.nix new file mode 100644 index 0000000..c621143 --- /dev/null +++ b/hosts/modules/sway.nix @@ -0,0 +1,19 @@ +{ config, pkgs, ... }: +{ + # Enable the Sway binary and hardware wrappers + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; + + # Hardware and security services that must be system-wide + services.gnome.gnome-keyring.enable = true; + security.polkit.enable = true; + programs.light.enable = true; # Allow brightness control + + # Move system-wide packages here + environment.systemPackages = with pkgs; [ + pavucontrol + light + ]; +}