Files
nixos-config/modules/home/sway.nix

109 lines
3.1 KiB
Nix

{ pkgs, lib, osConfig, ... }:
let
wallpaper = ../../assets/wallpapers/tim-foster-o4mP43oPGHk-unsplash.jpg;
modifier = "Mod4"; # Super
in
{
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = {
assigns = {}; # https://nix-community.github.io/home-manager/options.xhtml#opt-wayland.windowManager.sway.config.assigns
inherit modifier;
terminal = "kitty";
menu = "${pkgs.fuzzel}/bin/fuzzel";
bars = [{ command = "${pkgs.waybar}/bin/waybar"; }];
input."type:keyboard" = {
xkb_layout = "us";
repeat_delay = "250";
repeat_rate = "40";
};
input."type:touchpad" = {
tap = "enabled";
natural_scroll = "enabled";
};
output = osConfig.custom.displays // {
"*" = { bg = "${wallpaper} fill"; };
};
keybindings = lib.mkOptionDefault {
"Print" = "exec sh -c 'mkdir -p ~/Pictures/Screenshots && grim ~/Pictures/Screenshots/$(date +%Y%m%d-%H%M%S).png'";
"Shift+Print" = "exec sh -c 'mkdir -p ~/Pictures/Screenshots && grim -g \"$(slurp)\" ~/Pictures/Screenshots/$(date +%Y%m%d-%H%M%S).png'";
"Ctrl+Print" = "exec sh -c 'grim -g \"$(slurp)\" - | wl-copy'";
"XF86AudioRaiseVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%";
"XF86AudioLowerVolume" = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%";
"XF86AudioMute" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle";
"${modifier}+n" = "exec thunar";
"${modifier}+w" = "exec librewolf";
};
};
# TODO: make per host config
extraConfig = ''
# Lock + idle handling lives in swayidle/swaylock services below.
exec ${pkgs.mako}/bin/mako
workspace 1 output DP-2
workspace 2 output DP-2
workspace 3 output DP-2
workspace 4 output DP-2
workspace 5 output DP-2
workspace 6 output DP-1
workspace 7 output DP-1
workspace 8 output DP-1
workspace 9 output DP-1
workspace 10 output DP-4
assign [class="Spotify"] $ws10
assign [class="Discord"] $ws9
assign [class="obsidian"] $ws8
'';
};
# Notification daemon (mako), screenshot tool, idle/lock.
services.mako.enable = true;
programs.swaylock = {
enable = true;
package = pkgs.swaylock-effects;
};
services.swayidle = {
enable = true;
timeouts = [
{ timeout = 300; command = "${pkgs.swaylock-effects}/bin/swaylock -f"; }
# { timeout = 600; command = "${pkgs.sway}/bin/swaymsg \"output * dpms off\""; resumeCommand = "${pkgs.sway}/bin/swaymsg \"output * dpms on\""; }
];
};
programs.waybar = {
enable = true;
systemd.enable = false; # started from sway's `bars` block
};
home.packages = with pkgs; [
fuzzel # launcher
grim slurp # screenshots
wl-clipboard
wf-recorder
brightnessctl
playerctl
pavucontrol
networkmanagerapplet
];
# Wayland-friendly env vars.
home.sessionVariables = {
NIXOS_OZONE_WL = "1"; # Electron/Chromium under Wayland
MOZ_ENABLE_WAYLAND = "1"; # Firefox
XDG_CURRENT_DESKTOP = "sway";
XDG_SESSION_TYPE = "wayland";
};
}