aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/i3/keybindings.nix
blob: 5b16a05f823dcacefeb10b42f4cdf3c9a6752aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
  pkgs,
  lib,
  config,
}:

let
  mod = "Mod4";
in
{
  # --- General Applications ---
  "${mod}+r" = lib.mkIf config.tools.rofi.enable "exec ${lib.getExe pkgs.rofi} -show drun";
  "${mod}+t" = lib.mkIf config.tools.kitty.enable "exec ${lib.getExe pkgs.kitty}";
  "${mod}+f" =
    lib.mkIf config.tools.kitty.enable "exec ${lib.getExe pkgs.kitty} --title 'File Manager' --class floating-termial -e nnn";
  "${mod}+s" =
    lib.mkIf config.tools.kitty.enable "exec ${lib.getExe pkgs.kitty} --title 'Keybindings' --class floating-termial -e keybindings.sh";
  "${mod}+q" = "kill";

  # --- Media / Hardware Keys ---
  "XF86MonBrightnessDown" =
    lib.mkIf config.tools.brightnessctl.enable "exec ${lib.getExe pkgs.brightnessctl} set 5%-";
  "XF86MonBrightnessUp" =
    lib.mkIf config.tools.brightnessctl.enable "exec ${lib.getExe pkgs.brightnessctl} set +5%";
  "XF86AudioLowerVolume" =
    lib.mkIf config.tools.pamixer.enable "exec ${lib.getExe pkgs.pamixer} --decrease 5";
  "XF86AudioRaiseVolume" =
    lib.mkIf config.tools.pamixer.enable "exec ${lib.getExe pkgs.pamixer} --increase 5";
  "XF86AudioMute" =
    lib.mkIf config.tools.pamixer.enable "exec ${lib.getExe pkgs.pamixer} --toggle-mute";
  "XF86AudioPlay" =
    lib.mkIf config.tools.playerctl.enable "exec ${lib.getExe pkgs.playerctl} play-pause";

  # --- Window Management (Vim-style) ---
  # Focus
  "${mod}+h" = "focus left";
  "${mod}+j" = "focus down";
  "${mod}+k" = "focus up";
  "${mod}+l" = "focus right";

  # Move/Swap
  "${mod}+Shift+h" = "move left";
  "${mod}+Shift+j" = "move down";
  "${mod}+Shift+k" = "move up";
  "${mod}+Shift+l" = "move right";

  # Resize
  "${mod}+Control+h" = "resize shrink width 20 px or 20 ppt";
  "${mod}+Control+j" = "resize grow height 20 px or 20 ppt";
  "${mod}+Control+k" = "resize shrink height 20 px or 20 ppt";
  "${mod}+Control+l" = "resize grow width 20 px or 20 ppt";

  # Layout Modes
  "${mod}+d" = "floating toggle";
  "${mod}+m" = "fullscreen toggle";

  # --- Workspaces ---
  # Switch to workspace
  "${mod}+1" = "workspace number 1";
  "${mod}+2" = "workspace number 2";
  "${mod}+3" = "workspace number 3";
  "${mod}+4" = "workspace number 4";
  "${mod}+5" = "workspace number 5";
  "${mod}+6" = "workspace number 6";
  "${mod}+7" = "workspace number 7";
  "${mod}+8" = "workspace number 8";
  "${mod}+9" = "workspace number 9";
  "${mod}+0" = "workspace number 10";

  # Move window to workspace
  "${mod}+Shift+1" = "move container to workspace number 1; workspace number 1";
  "${mod}+Shift+2" = "move container to workspace number 2; workspace number 2";
  "${mod}+Shift+3" = "move container to workspace number 3; workspace number 3";
  "${mod}+Shift+4" = "move container to workspace number 4; workspace number 4";
  "${mod}+Shift+5" = "move container to workspace number 5; workspace number 5";
  "${mod}+Shift+6" = "move container to workspace number 6; workspace number 6";
  "${mod}+Shift+7" = "move container to workspace number 7; workspace number 7";
  "${mod}+Shift+8" = "move container to workspace number 8; workspace number 8";
  "${mod}+Shift+9" = "move container to workspace number 9; workspace number 9";
  "${mod}+Shift+0" = "move container to workspace number 10; workspace number 10";

  # --- Screenshots ---
  "${mod}+p" =
    lib.mkIf config.tools.maim.enable "exec \"${lib.getExe pkgs.maim} -s | xclip -selection clipboard -t image/png\"";
  "${mod}+Shift+p" =
    lib.mkIf config.tools.maim.enable "exec \"mkdir -p ~/Pictures/Screenshots && ${lib.getExe pkgs.maim} -s ~/Pictures/Screenshots/screenshot-$(date +%Y%m%d-%H%M%S).png\"";

  # --- Screen Recordings ---
  "${mod}+Mod1+r" = lib.mkIf config.tools.ffmpeg.enable (
    let
      pidFile = "/tmp/ffmpeg-screenrecord.pid";
      outDir = "~/Videos/Recordings";
    in
    "exec \""
    + "if [ -f ${pidFile} ]; then "
    + "kill $(cat ${pidFile}) && rm ${pidFile}; "
    + "else "
    + "mkdir -p ${outDir} && "
    + "${lib.getExe pkgs.ffmpeg-full} -f x11grab -i $DISPLAY "
    + "-framerate 30 -c:v libx264 -preset ultrafast -crf 23 "
    + "${outDir}/recording-$(date +%Y%m%d-%H%M%S).mp4 "
    + "& echo $! > ${pidFile}; "
    + "fi\""
  );
}