nixos-config/modules/programs/sway/default.nix

81 lines
2.6 KiB
Nix

{
config
, lib, pkgs
, stdenv
, ...
}:
let
modifier = "Mod1";
writeShellScript = pkgs.writeShellScript;
nwggrid = "${pkgs.nwg-launchers}/bin/nwggrid";
gopass = "${pkgs.gopass}/bin/gopass";
# TODO: Add shebangs
passwordDmenu = writeShellScript "password_menu" ''
password=$(${gopass} list --flat | ${pkgs.bemenu}/bin/bemenu)
${gopass} show -c "$password"
'';
mkWrapperScript = binary: args: let
pname = baseNameOf binary;
in writeShellScript "${pname}-wrapper" ''
ps -aux | grep ${pname} &> /dev/null
[[ "$?" -eq 0 ]] && pkill ${pname}
${binary} ${args}
'';
makoWrapper = mkWrapperScript "${pkgs.mako}/bin/mako" "--default-timeout=3000";
waybarWrapper = mkWrapperScript "${pkgs.waybar}/bin/waybar" "";
kanshiWrapper = mkWrapperScript "${pkgs.kanshi}/bin/kanshi" "";
in {
home-manager.users."${config.system.singleUser}" = {
wayland.windowManager.sway = {
enable = true;
config = {
bars = [ ];
startup = [
{ command = "${makoWrapper}"; always = true; }
{ command = "${waybarWrapper}"; always = true; }
{ command = "${kanshiWrapper}"; always = true; }
{ command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; always = true; }
];
modifier = "${modifier}";
gaps = {
inner = 5;
outer = 7;
};
input = {
"*" = { xkb_layout = "de"; };
"2:7:SynPS/2_Synaptics_TouchPad" = {
tap = "enabled";
natural_scroll = "disabled";
dwt = "enabled";
};
"2:10:TPPS/2_Elan_TrackPoint" = { dwt = "enabled"; };
};
output = {
"*" = { adaptive_sync = "on"; };
};
keybindings = let
speakers = "alsa_output.pci-0000_00_1f.3.analog-stereo";
in lib.mkOptionDefault {
"${modifier}+Return" = "exec alacritty";
"${modifier}+e" = "exec emacs";
"${modifier}+Shift+q" = "kill";
"${modifier}+f" = "exec firefox";
"${modifier}+d" = "exec ${pkgs.nwg-launchers}/bin/nwggrid";
"${modifier}+p" = "exec ${passwordDmenu}";
"Mod4+s" = "exec systemctl suspend";
# TODO: Screenlock
#"Mod4+l" = "exec ..."
"F1" = "exec pactl set-sink-volume ${speakers} toggle";
"F2" = "exec pactl set-sink-volume ${speakers} -10%";
"F3" = "exec pactl set-sink-volume ${speakers} +10%";
"F5" = "exec brightnessctl --device=intel_backlight set 10%-";
"F6" = "exec brightnessctl --device=intel_backlight set +10%";
};
};
};
};
}