Files
nixos/home-manager/sway.nix
T
2025-07-10 14:28:15 +02:00

210 lines
6.8 KiB
Nix

{ config, pkgs, lib, ... }:
let
# define some constants
mod = "Mod4";
alt = "Mod1";
num_workspaces = 9;
ws = builtins.listToAttrs (builtins.genList (n: {
name = "ws${toString (n + 1)}";
value = toString (n + 1);
}) num_workspaces);
in
{
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = rec {
modifier = mod;
terminal = "alacritty";
fonts = {
names = [ "MesloLGS NF" ];
size = 11.0;
};
input = {
"type:touchpad" = {
tap = "enabled";
natural_scroll = "enabled";
tap_button_map = "lrm";
};
"type:keyboard" = {
xkb_layout = "us";
xkb_variant = "intl";
};
};
gaps = {
inner = 8;
outer = -4;
smartGaps = true;
smartBorders = "on";
};
keybindings = lib.mkOptionDefault {
"${mod}+Return" = "exec alacritty --command tmux";
"${mod}+Ctrl+Return" = "exec alacritty";
"${mod}+Shift+Return" = "exec rofi -show combi";
"${mod}+Print" = "exec flameshot full -c";
"${mod}+Shift+Print" = "exec flameshot gui";
"${mod}+Ctrl+Shift+Print" = "exec simplescreenrecorder --start-hidden --start-recording";
"XF86AudioLowerVolume" = "exec pamixer --decrease 5";
"XF86AudioRaiseVolume" = "exec pamixer --increase 5";
"XF86AudioMute" = "exec pamixer -t";
"${mod}+XF86AudioMute" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"XF86AudioPlay" = "exec playerctl play-pause";
"XF86AudioNext" = "exec playerctl next";
"XF86AudioPrev" = "exec playerctl previous";
"${mod}+XF86AudioRaiseVolume" = "exec playerctl next";
"${mod}+XF86AudioLowerVolume" = "exec playerctl previous";
"XF86MonBrightnessUp" = "exec light -A 5; notify-send 'Brightness set to $(light)'";
"XF86MonBrightnessDown" = "exec light -U 5; notify-send 'Brightness set to $(light)'";
"${mod}+XF86MonBrightnessDown" = "exec light -S 0.2; notify-send 'Brightness set to min'";
"${mod}+XF86MonBrightnessUp" = "exec light -S 100; notify-send 'Brightness set to max'";
"XF86Calculator" = "exec qalculate-gtk";
"${mod}+Shift+c" = "kill";
"${mod}+u" = "border none";
"${mod}+y" = "border pixel 1";
"${mod}+n" = "border normal";
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
"${mod}+Left" = "focus left";
"${mod}+Down" = "focus down";
"${mod}+Up" = "focus up";
"${mod}+Right" = "focus right";
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
"${mod}+Shift+Left" = "move left";
"${mod}+Shift+Down" = "move down";
"${mod}+Shift+Up" = "move up";
"${mod}+Shift+Right" = "move right";
"${mod}+b" = "workspace back_and_forth";
"${mod}+Shift+b" = "move container to workspace back_and_forth; workspace back_and_forth";
"${mod}+Ctrl+Right" = "workspace next";
"${mod}+Ctrl+Left" = "workspace prev";
"${mod}+Shift+minus" = "move scratchpad";
"${mod}+minus" = "scratchpad show";
"${mod}+z" = "split h; exec notify-send 'Tile horizontally'";
"${mod}+v" = "split v; exec notify-send 'Tile vertically'";
"${mod}+q" = "split toggle";
"${mod}+f" = "fullscreen toggle";
"${mod}+s" = "layout stacking";
"${mod}+w" = "layout tabbed";
"${mod}+e" = "layout toggle split";
"${mod}+Shift+space" = "floating toggle";
"${mod}+space" = "focus mode_toggle";
"${mod}+Shift+s" = "sticky toggle";
"${mod}+a" = "focus parent";
"${mod}+Ctrl+l" = "exec i3lock -c 000000";
"${mod}+Shift+r" = "reload";
} // builtins.listToAttrs (builtins.concatMap (n: let
key = toString (n + 1);
in [
{
name = "${mod}+${key}";
value = "workspace ${key}";
}
{
name = "${mod}+Ctrl+${key}";
value = "move container to workspace ${key}";
}
{
name = "${mod}+Shift+${key}";
value = "move container to workspace ${key}; workspace ${key}";
}
]) (lib.range 0 8));
assigns = {
"2: web" = [{ class = "^Brave$"; }];
"9: mail" = [{ class = "Thunderbird"; }];
};
modes = {
resize = {
"h" = "resize shrink width 4 px or 4 ppt";
"j" = "resize grow height 4 px or 4 ppt";
"k" = "resize shrink height 4 px or 4 ppt";
"l" = "resize grow width 4 px or 4 ppt";
"Left" = "resize shrink width 10 px or 10 ppt";
"Down" = "resize grow height 10 px or 10 ppt";
"Up" = "resize shrink height 10 px or 10 ppt";
"Right" = "resize grow width 10 px or 10 ppt";
"Return" = "mode default";
"Escape" = "mode default";
};
};
colors = {
focused = {
border = "#ff8800";
background = "#2F3D44";
text = "#FF8800";
indicator = "#FDF6E3";
childBorder = "#ff8800";
};
focusedInactive = {
border = "#333333";
background = "#222222";
text = "#444444";
indicator = "#454948";
childBorder = "#222222";
};
unfocused = {
border = "#2F3D44";
background = "#2F3D44";
text = "#FF8800";
indicator = "#454948";
childBorder = "#222222";
};
urgent = {
border = "#CB4B16";
background = "#FDF6E3";
text = "#FF8800";
indicator = "#268BD2";
childBorder = "#222222";
};
placeholder = {
border = "#000000";
background = "#0c0c0c";
text = "#ffffff";
indicator = "#000000";
childBorder = "#222222";
};
background = "#2B2C2B";
};
};
extraConfig = ''
default_border none
floating_modifier ${mod}
# === Floating Windows ===
for_window [title="alsamixer"] floating enable border pixel 1
for_window [title="Qalculate!"] floating enable border normal
for_window [class="Psensor"] floating enable border normal
for_window [title="lxrandr"] floating enable border normal
for_window [class="Blueman-manager"] floating enable border normal
for_window [class="GParted"] floating enable border normal
for_window [class="pavucontrol"] floating enable
for_window [class="Volume Control"] floating enable
for_window [class="(?i)VirtualBox"] floating enable border normal
'';
};
}