Refactor sway stuff

This commit is contained in:
Alexander Wainwright
2025-12-21 18:57:15 +10:00
parent c6efec9bb7
commit 1f76671a71
5 changed files with 80 additions and 34 deletions

View File

@@ -33,6 +33,12 @@
};
} else {};
imports = [
] ++ (if isDesktop then [
./sway.nix
] else []);
home.shellAliases = {
e = "ls -lh";
tree = "eza --tree";

52
alex/sway.nix Normal file
View File

@@ -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;
}

View File

@@ -12,6 +12,7 @@
../modules/desktop.nix
../modules/brother-printer.nix
../modules/home.nix
../modules/sway.nix
];
# Bootloader.

View File

@@ -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;

19
hosts/modules/sway.nix Normal file
View File

@@ -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
];
}