From 916dd9fd913c838c13cddd4edb989b6f3b983648 Mon Sep 17 00:00:00 2001
From: Michael Thomas <michaelhthomas@outlook.com>
Date: Thu, 18 Jan 2024 13:16:29 -0500
Subject: [PATCH] feat(mac): add yabai

---
 flake.nix         |  1 +
 modules/yabai.nix | 58 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 modules/yabai.nix

diff --git a/flake.nix b/flake.nix
index c5eb652..7653ea0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -145,6 +145,7 @@
             home-manager.users.michael = import ./user/environments/mac/home.nix;
           }
 
+          ./modules/yabai.nix
           ./machines/mac/configuration.nix
         ];
       };
diff --git a/modules/yabai.nix b/modules/yabai.nix
new file mode 100644
index 0000000..bc4b6d2
--- /dev/null
+++ b/modules/yabai.nix
@@ -0,0 +1,58 @@
+{...}: {
+  services.yabai = {
+    enable = true;
+    config = {
+      mouse_follows_focus = "off";
+      focus_follows_mouse = "off";
+      window_origin_display = "default";
+      window_placement = "second_child";
+      window_zoom_persist = "on";
+      window_shadow = "on";
+      window_animation_duration = 0;
+      window_animation_frame_rate = 120;
+      window_opacity_duration = 0;
+      active_window_opacity = 1;
+      normal_window_opacity = 0;
+      window_opacity = "off";
+      insert_feedback_color = "0xffd75f5f";
+      split_ratio = 0;
+      split_type = "auto";
+      auto_balance = "off";
+      top_padding = 12;
+      bottom_padding = 12;
+      left_padding = 12;
+      right_padding = 12;
+      window_gap = 06;
+      layout = "bsp";
+      mouse_modifier = "fn";
+      mouse_action1 = "move";
+      mouse_action2 = "resize";
+      mouse_drop_action = "swap";
+    };
+  };
+
+  services.skhd = {
+    enable = true;
+    skhdConfig = ''
+      alt - h: yabai -m window --focus west
+      alt - j: yabai -m window --focus south
+      alt - k: yabai -m window --focus north
+      alt - l: yabai -m window --focus east
+
+      shift + alt - h : yabai -m window --warp east
+      shift + alt - j : yabai -m window --warp north
+      shift + alt - k : yabai -m window --warp south
+      shift + alt - l : yabai -m window --warp west
+
+      cmd + alt - 1 : yabai -m space --focus 1
+      cmd + alt - 2 : yabai -m space --focus 2
+      cmd + alt - 3 : yabai -m space --focus 3
+      cmd + alt - 4 : yabai -m space --focus 4
+      cmd + alt - 5 : yabai -m space --focus 5
+      cmd + alt - 6 : yabai -m space --focus 6
+      cmd + alt - 7 : yabai -m space --focus 7
+      cmd + alt - 8 : yabai -m space --focus 8
+      cmd + alt - 9 : yabai -m space --focus 9
+    '';
+  };
+}