2021-08-30 17:42:45 +00:00
|
|
|
{
|
|
|
|
config
|
2021-10-22 19:43:41 +00:00
|
|
|
, lib, pkgs
|
2021-09-07 13:41:08 +00:00
|
|
|
, stdenv
|
2021-10-22 19:43:41 +00:00
|
|
|
, ...
|
2021-08-30 17:42:45 +00:00
|
|
|
}:
|
|
|
|
|
2021-09-07 13:41:08 +00:00
|
|
|
let
|
2021-10-22 19:43:41 +00:00
|
|
|
modifier = "Mod1";
|
|
|
|
writeShellScript = pkgs.writeShellScript;
|
|
|
|
|
|
|
|
nwggrid = "${pkgs.nwg-launchers}/bin/nwggrid";
|
|
|
|
gopass = "${pkgs.gopass}/bin/gopass";
|
|
|
|
# TODO: Add shebangs
|
2021-09-07 13:41:08 +00:00
|
|
|
passwordDmenu = writeShellScript "password_menu" ''
|
2021-10-22 19:43:41 +00:00
|
|
|
password=$(${gopass} list --flat | ${pkgs.bemenu}/bin/bemenu)
|
|
|
|
${gopass} show -c "$password"
|
2021-09-07 13:41:08 +00:00
|
|
|
'';
|
2021-10-22 19:43:41 +00:00
|
|
|
mkWrapperScript = binary: args: let
|
|
|
|
pname = baseNameOf binary;
|
|
|
|
in writeShellScript "${pname}-wrapper" ''
|
|
|
|
ps -aux | grep ${pname} &> /dev/null
|
|
|
|
[[ "$?" -eq 0 ]] && pkill ${pname}
|
2021-08-30 17:42:45 +00:00
|
|
|
|
2021-10-22 19:43:41 +00:00
|
|
|
${binary} ${args}
|
|
|
|
'';
|
2021-10-26 15:30:05 +00:00
|
|
|
swayncWrapper = mkWrapperScript "${pkgs.swaync}/bin/swaync" "";
|
2021-10-22 19:43:41 +00:00
|
|
|
waybarWrapper = mkWrapperScript "${pkgs.waybar}/bin/waybar" "";
|
|
|
|
kanshiWrapper = mkWrapperScript "${pkgs.kanshi}/bin/kanshi" "";
|
2021-10-26 15:30:05 +00:00
|
|
|
nwggridWrapper = mkWrapperScript "${pkgs.nwg-launchers}/bin/nwggrid-server" "";
|
2021-10-22 20:50:57 +00:00
|
|
|
# TODO: Fuse this with kanshi
|
|
|
|
swayIdleWrapper = mkWrapperScript "${pkgs.swayidle}/bin/swayidle" "-w before-sleep '${pkgs.swaylock}/bin/swaylock -f --image $(find ~/Data/Wallpaper/horizontal/ -maxdepth 1 -type f | shuf -n 1)'";
|
2021-11-01 20:33:21 +00:00
|
|
|
|
|
|
|
cfg = config.ptw.programs.sway;
|
2021-10-22 19:43:41 +00:00
|
|
|
in {
|
2021-11-01 20:33:21 +00:00
|
|
|
options.ptw.programs.sway = {
|
|
|
|
enable = lib.mkEnableOption "Configure sway using HomeManager";
|
2022-02-14 17:34:04 +00:00
|
|
|
extraSessionCommands = lib.mkOption {
|
|
|
|
description = "Commands to be run before sway is started. See programs.sway.extraSessionCommands";
|
|
|
|
default = "";
|
|
|
|
};
|
2021-11-01 20:33:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
2021-11-04 18:51:49 +00:00
|
|
|
xdg.portal = {
|
|
|
|
enable = true;
|
|
|
|
extraPortals = [
|
|
|
|
pkgs.xdg-desktop-portal-wlr
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-11-09 19:16:22 +00:00
|
|
|
qt5.style = "adwaita-dark";
|
|
|
|
|
|
|
|
environment = {
|
2022-05-30 12:53:22 +00:00
|
|
|
systemPackages = with pkgs; [ adwaita-qt wdisplays ];
|
2021-11-09 19:16:22 +00:00
|
|
|
sessionVariables = {
|
|
|
|
# sway
|
|
|
|
#"_JAVA_AWT_NONREPARENTING" = 1;
|
2021-11-04 18:51:49 +00:00
|
|
|
|
2021-11-09 19:16:22 +00:00
|
|
|
# Wayland
|
|
|
|
"QT_QPA_PLATFORM" = "wayland-egl";
|
|
|
|
"ECORE_EVAS_ENGINE" = "wayland-egl";
|
|
|
|
"ELM_ENGINE" = "wayland-egl";
|
|
|
|
"SDL_VIDEODRIVER" = "wayland";
|
|
|
|
};
|
2021-11-04 18:51:49 +00:00
|
|
|
};
|
|
|
|
|
2022-02-14 17:34:04 +00:00
|
|
|
programs.sway = {
|
|
|
|
enable = true;
|
|
|
|
extraSessionCommands = cfg.extraSessionCommands;
|
|
|
|
};
|
2021-11-01 20:33:21 +00:00
|
|
|
home-manager.users."${config.ptw.system.singleUser}" = {
|
|
|
|
wayland.windowManager.sway = {
|
|
|
|
enable = true;
|
2022-02-14 17:34:04 +00:00
|
|
|
extraSessionCommands = cfg.extraSessionCommands;
|
2021-11-01 20:33:21 +00:00
|
|
|
config = {
|
|
|
|
bars = [ ];
|
|
|
|
startup = [
|
|
|
|
{ command = "${nwggridWrapper}"; always = true; }
|
|
|
|
{ command = "${swayncWrapper}"; always = true; }
|
|
|
|
{ command = "${waybarWrapper}"; always = true; }
|
|
|
|
{ command = "${kanshiWrapper}"; always = true; }
|
|
|
|
{ command = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1"; always = true; }
|
|
|
|
{ command = "${swayIdleWrapper}"; always = true; }
|
2021-11-04 16:42:12 +00:00
|
|
|
] ++ lib.optional config.ptw.system.i18n.enable {
|
2021-11-04 17:08:36 +00:00
|
|
|
command = "${pkgs.fcitx5}/bin/fcitx5 -d";
|
2021-11-04 16:42:12 +00:00
|
|
|
always = true;
|
|
|
|
};
|
2021-11-01 20:33:21 +00:00
|
|
|
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"; };
|
|
|
|
};
|
2021-11-06 20:38:12 +00:00
|
|
|
# NOTE: Somehow the cursor sometimes lags a bit
|
|
|
|
#output = {
|
|
|
|
# "*" = { adaptive_sync = "on"; };
|
|
|
|
#};
|
2021-11-01 20:33:21 +00:00
|
|
|
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 -client";
|
|
|
|
"${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%";
|
2021-08-30 17:42:45 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|