nix-configs/modules/desktop.nix

87 lines
3.2 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.jade.desktop;
window-screenshot = pkgs.writeShellScriptBin "window-screenshot.sh" ''
unset x y w h
eval $(xwininfo -id $(xdotool getactivewindow) |
sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
-e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
-e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
-e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
echo -n "''$x ''$y ''$w ''$h"
flameshot gui --region "''${w}x''${h}+''${x}+''${y}" -c -p ~/Pictures/screenshots/
'';
in with lib; {
options.jade.desktop = {
enable = mkEnableOption "Enable the i3 setup";
};
config = mkIf cfg.enable {
home-manager.users.jade = { pkgs, ... }: {
home.packages = with pkgs; [
gnome.gdm i3lock-fancy rofi rofimoji volumeicon feh xorg.xinput dunst
arandr lxappearance gruvbox-dark-gtk gruvbox-dark-icons-gtk
gruvterial-theme flameshot tesseract5 imagemagick xclip polybar kitty
xkeysnail gtk-engine-murrine playerctl xmacro
window-screenshot
];
xsession = {
enable = true;
windowManager.i3 = {
enable = true;
package = pkgs.i3-gaps;
config = {
terminal = "kitty";
modifier = "Mod4";
gaps = {
inner = 15;
outer = 0;
smartGaps = true;
};
modes = {
resize = with {
aaa = builtins.trace "foo" "bar";
mod = builtins.trace config config.xsession.windowManager.i3.config.modifier;
}; {
"${mod}+h" = "resize shrink width 10 px or 10 ppt";
"${mod}+j" = "resize grow height 10 px or 10 ppt";
"${mod}+k" = "resize shrink height 10 px or 10 ppt";
"${mod}+l" = "resize grow width 10 px or 10 ppt";
"Return" = "mode default";
"Escape" = "mode default";
"${mod}+r" = "mode default";
};
};
keybindings = with {
mod = config.xsession.windowManager.i3.config.modifier;
}; {
# switch window focus
"${mod}+h" = "focus left";
"${mod}+j" = "focus down";
"${mod}+k" = "focus up";
"${mod}+l" = "focus right";
# move windows
"${mod}+Shift+h" = "move left";
"${mod}+Shift+j" = "move down";
"${mod}+Shift+k" = "move up";
"${mod}+Shift+l" = "move right";
# layout shit
"${mod}+shift+semicolon" = "split h";
"${mod}+semicolon" = "split v";
"${mod}+f" = "fullscreen toggle";
"${mod}+Shift+w" = "layout tabbed";
"${mod}+e" = "layout toggle split";
"${mod}+Shift+space" = "floating toggle";
# focus parents/children
"${mod}+Shift+a" = "focus parent";
"${mod}+c" = "focus child";
# custom script shit
"${mod}+w" = "exec window-screenshot.sh";
};
};
};
};
};
};
}