System/home-manager/modules/programs/sway.nix
2025-07-15 01:33:34 -04:00

165 lines
4.9 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
config,
lib,
pkgs,
inputs',
...
}: let
fuzzel-command = ''fuzzel -f "Iosevka Sans Quasi:size=16" -b "181818cc" -S "b9b9b9ff" -s "252525cc" -t "777777ff" -B 5 -r 5 -C "70b433cc" --width=80 --lines=25'';
in {
home.packages = with pkgs; [
inputs'.nixpkgs-unstable.legacyPackages.xwayland-satellite
# Clipboard
wl-clipboard
cliphist
# Launcher
fuzzel
# Polkit
kdePackages.polkit-kde-agent-1
# Locking
swaylock-effects
swayidle
];
wayland.windowManager.sway = {
enable = true;
package = null;
swaynag.enable = true;
xwayland = false;
config = let
modifier = "Mod4";
in {
inherit modifier;
# Disable bars in the sway config, we'll launch ours through systemd
bars = [];
# Cosmetic settings
gaps = let
big = 5;
small = 3;
in {
inner = big;
outer = small;
smartBorders = "on";
smartGaps = true;
};
# Making trying to go to the current workspace send you back to your previous one
workspaceAutoBackAndForth = true;
# Use foot client as the default terminal
terminal = "footclient";
# Keybinding configuration
keybindings = {
"${modifier}+d" = "exec ${fuzzel-command} --prompt=' '";
"${modifier}+x" = "exec cliphist list | ${fuzzel-command} --prompt=' ' --dmenu | cliphist decode | wl-copy";
};
# Start programs when sway starts
startup = [
# Use xwayland-satellite as our xwayland server to disable scaling for x11 apps
{command = "env DISPLAY=:0 xwayland-satellite";}
# Setup wl-paste for clipboard memory
{command = "wl-paste --watch cliphist store --250";}
];
# Floating window rules
floating.criteria = [
# Basic window role/type detection
#{ window_role = "pop-up"; }
#{ window_role = "bubble"; }
#{ window_role = "dialog"; }
#{ window_type = "dialog"; }
#{ window_role = "task_dialog"; }
#{ window_type = "menu"; }
#{ window_role = "About"; }
#{ window_role = "Preferences"; }
# "Common" app id detection
#{ app_id = "floating"; }
#{ app_id = "floating_update"; }
#{ class = "(?i)pinentry"; }
#{ app_id = "Yad"; }
#{ app_id = "yad"; }
{app_id = ".*polkit.*";}
{title = "^Open File$";}
{title = "^Open Files$";}
# { title = "^Open$"; }
{title = "^Choose Files$";}
{title = "^Save As$";}
# { title = "^$"; }
{title = "Save File";}
{title = "File Operation Progress";}
{title = "(?i)(?:copying|deleting|moving)";}
# Firefox stuff
{title = "About Mozilla Firefox";}
{title = "Firefox - Sharing Indicator";}
{title = "Firefox Sharing Indicator";}
# Specific applications
{app_id = "pavucontrol";}
{app_id = ".*blueman-manager.*";}
];
window.commands = [
{
command = "floating enable, sticky enable";
criteria = {
app_id = "firefox(-\w*)?";
title = "Library";
};
}
{
command = "floating enable, sticky enable";
criteria = {
title = "[Pp]icture-in-[Pp]icture";
};
}
];
};
systemd = {
enable = true;
variables = ["--all"];
};
wrapperFeatures = {
gtk = true;
};
};
# Services to have sway act like a desktop environment
services.blueman-applet.enable = true;
systemd.user.services.polkit-kde = {
Unit = {
Description = "Polkit kde authentication agent";
After = ["graphical-session.target"];
};
Service = {
Type = "simple";
ExecStart = "${pkgs.libsForQt5.polkit-kde-agent}/libexec/polkit-kde-authentication-agent-1";
Restart = "on-failure";
};
Install = {
WantedBy = ["graphical-session.target"];
};
};
services.swayidle = let
swaylock-package = pkgs.swaylock-effects;
swaylock-command = ''--screenshots --grace 30 --indicator --clock --timestr "%-I:%M:%S %p" --datestr "%A %Y-%M-%d" --effect-blur 20x3'';
in {
enable = true;
timeouts = [
# Lock the screen after 5 minutes of inactivity
{
timeout = 300;
command = "${swaylock-package}/bin/swaylock ${
builtins.replaceStrings ["%"] ["%%"] swaylock-command
}";
}
# Turn off the displays after 10 minutes of inactivity
{
timeout = 600;
command = ''swaymsg "output * dpms off"'';
resumeCommand = ''swaymsg "output * dpms on"'';
}
];
};
}
# TODOs:
# - [ ] Dropdown terminal
# - [ ] SwayFX and eyecandy configuration
# - [ ] Brightness control
# - [ ] Volume control
# - [ ] Floating, centered, and specific portion of screen for all configuration apps
# - [ ] Bar
# - [ ] Notifications
# - [x] Port over default floating rules