nixos/modules/home-manager/sway.nix

359 lines
8.6 KiB
Nix

{
config,
pkgs,
lib,
...
}: {
home.packages = with pkgs; [
waybar # status bar
swaylock # screen locking
swayidle # automatic screen locking after system idle time
kanshi # hotswap displays
foot # terminal
keepassxc # used for secrets instead of gnome-keyring
];
wayland.windowManager.sway = {
enable = true;
systemd = {
enable = true;
xdgAutostart = false;
};
wrapperFeatures = {
gtk = true;
};
config = {
input = {
"*" = {
xkb_layout = "de";
xkb_options = "caps:ctrl_modifier";
xkb_numlock = "enable";
};
"type:touchpad" = {
tap = "enable";
natural_scroll = "enable";
};
};
modifier = "Mod4";
keybindings = let
modifier = config.wayland.windowManager.sway.config.modifier;
in
lib.mkOptionDefault {
# brightness
"XF86MonBrightnessDown" = "exec ${pkgs.light}/bin/light -U 5";
"XF86MonBrightnessUp" = "exec ${pkgs.light}/bin/light -A 5";
# volume
"XF86AudioRaiseVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +1%'";
"XF86AudioLowerVolume" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -1%'";
"XF86AudioMute" = "exec '${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle'";
# custom pause mode similar to typical system shutdown menus
"${modifier}+F12" = "mode pause-break";
};
# use foot as default terminal
terminal = "foot";
assigns = {
"1" = [{app_id = "firefox";}];
"2" = [{app_id = "foot";}];
};
bars = [];
menu = "${pkgs.tofi}/bin/tofi-drun | ${pkgs.findutils}/bin/xargs swaymsg exec --";
fonts = {
names = ["FiraCode Nerd Font"];
size = 11.0;
};
modes = {
pause-break = {
e = "exec --no-startup-id swaymsg exit, mode default";
s = "exec --no-startup-id ${pkgs.dash}/bin/dash -c '${pkgs.swaylock}/bin/swaylock & systemctl suspend-then-hibernate', mode default";
r = "exec --no-startup-id systemctl reboot";
End = "exec --no-startup-id systemctl poweroff";
Return = "mode default";
Escape = "mode default";
};
};
startup = [
{command = "dbus-sway-environment";}
{command = "configure-gtk";}
{command = "${pkgs.keepassxc}/bin/keepassxc";}
{command = "${pkgs.waybar}/bin/waybar";}
{command = "${pkgs.foot}/bin/foot";}
];
};
};
programs.waybar = {
enable = true;
settings = {
mainBar = {
layer = "top";
position = "top";
height = 26;
modules-left = ["sway/workspaces" "sway/mode"];
modules-center = ["sway/window"];
modules-right = ["mpd" "tray" "sway/language" "clock" "backlight" "battery" "network"];
"sway/workspaces" = {
disable-scroll = true;
all-outputs = false;
format = "<span size='150%'>{icon}</span> {name}";
format-icons = {
"main" = "󰈹";
"term" = "";
"msg" = "󰷹";
"music" = "󰫔";
"urgent" = "";
"focused" = "";
"default" = "";
};
};
"mpd" = {
format = "{stateIcon}{consumeIcon}{randomIcon}{repeatIcon}{singleIcon} {title} ({elapsedTime:%M:%S}/{totalTime:%M%S}) {volume}";
format-stopped = "{stateIcon}{randomIcon}{repeatIcon}{singleIcon} Stopped {volume}";
format-disconnected = "";
unkown-tag = "N/A";
interval = 2;
consume-icons = {
on = "󰮯";
off = "";
};
random-icons = {
on = "";
off = "";
};
repeat-icons = {
on = "󰑖";
off = "";
};
single-icons = {
on = "󰑘";
off = "";
};
state-icons = {
paused = "󰏤";
playing = "󰐊";
};
max-length = 50;
};
"tray" = {
spacing = 10;
};
"sway/language" = {
format = "{shortDescription}";
tooltip = false;
};
"clock" = {
interval = 60;
format = "{:%a %d.%m %I:%M}";
};
"backlight" = {
format = "{percent}% {icon}";
format-icons = ["󰹐" "󱩎" "󱩏" "󱩐" "󱩑" "󱩒" "󱩓" "󱩔" "󱩕" "󱩖" "󰛨"];
};
"network" = {
format-wifi = "{essid} ({signalStrength}%) 󰖩";
format-ethernet = "{ipaddr}/{cidr} 󰈀";
tooltip-format = "{ifname} via {gwaddr} 󰌘";
format-disconnected = "󰌙";
};
};
};
style = ''
* {
border: none;
border-radius: 0;
padding: 0;
margin: 0;
font-size: 11px;
text-align: center;
}
window#waybar {
background: #292828;
color: #ffffff;
}
#workspaces button {
margin-right: 2px;
padding-left: 2px;
padding-right: 2px;
color: #ffffff;
}
#workspaces button:hover, #workspaces button:active {
background-color: #292828;
color: #ffffff;
}
#workspaces button.focused {
background-color: #383737;
color: #00ffee;
}
#mpd {
margin-right: 2px;
}
#tray {
margin-right: 2px;
}
#language {
margin-right: 2px;
}
#clock {
margin-right: 2px;
}
#backlight {
padding-right: 7px;
margin-right: 2px;
}
#battery {
padding-right: 7px;
margin-right: 2px;
}
#network {
padding-right: 7px;
margin-right: 2px;
}
'';
};
services.kanshi = {
enable = true;
profiles = {
laptop.outputs = [
{
criteria = "eDP-1";
position = "0,0";
}
];
dock_luhbots.outputs = [
{
criteria = "eDP-1";
position = "0,1080";
}
{
criteria = "Dell Inc. DELL U2422HE GRCPH83";
position = "0,0";
}
{
criteria = "NEC Corporation E243WMi 7X313185NB";
transform = "90";
position = "1920,0";
}
];
laptop_hannspree.outputs = [
{
criteria = "eDP-1";
position = "320,1440";
}
{
criteria = "HannStar Display Corp HC281UPB ";
position = "0,0";
mode = "3840x2160@60";
scale = 1.5;
}
];
};
};
# Theming
gtk = {
enable = true;
cursorTheme = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
};
iconTheme = {
package = pkgs.whitesur-icon-theme;
name = "WhiteSur-dark";
};
theme = {
package = pkgs.whitesur-gtk-theme;
name = "WhiteSur-Dark";
};
gtk3.extraConfig = {
gtk-dialogs-use-header = false;
gtk-cursor-theme-size = 0;
gtk-toolbar-style = "GTK_TOOLBAR_BOTH_HORIZ";
gtk-toolbar-icon-style = "GTK_ICON_SIZE_LARGE_TOOLBAR";
gtk-button-images = 0;
gtk-menu-images = 0;
gtk-enable-event-sounds = 0;
gtk-enable-input-feedback-sounds = 1;
gtk-xft-antialias = 1;
gtk-xft-hinting = 1;
gtk-xft-hintstyle = "hintslight";
gtk-xft-rgba = "none";
};
};
home.pointerCursor = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors-white";
size = 24;
x11.enable = true;
x11.defaultCursor = "capitaine-cursors-white";
};
xsession.enable = true;
home.file."tofi" = {
enable = true;
target = ".config/tofi/config";
text = ''
# fullscreen theming
width = 100%
height = 100%
border-width = 0
outline-width = 0
padding-top = 32
result-spacing = 25
font = FiraCode Nerd Font
background-color = #000D
text-color = #00FFEE
selection-color = #EEFF00
hint-font = false
# search behavior
history = true
fuzzy-match = true
'';
};
services.mako = {
enable = true;
actions = true;
anchor = "top-right";
backgroundColor = "#313131";
borderColor = "#00FFEE";
progressColor = "#338833";
textColor = "#e0e0e0";
extraConfig = ''
[urgency=low]
border-color=#008877
'';
borderRadius = 10;
borderSize = 2;
height = 100;
width = 400;
defaultTimeout = 10000; # ms
font = "FiraCode Nerd Font 11";
icons = true;
markup = true;
};
}