ctucx.git: nixfiles

ctucx' nixfiles

commit 368f2a4c562c8b4e4b092c41325c042b75b4cf6b
parent 18d4a1762036135410af28da3f9fbad7b09fbf33
Author: Leah (ctucx) <git@ctu.cx>
Date: Mon, 17 Jun 2024 23:02:42 +0200

configurations/darwin: add `aerospace`
2 files changed, 154 insertions(+), 0 deletions(-)
A
configurations/darwin/aerospace.nix
|
153
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M
configurations/darwin/default.nix
|
1
+
diff --git a/configurations/darwin/aerospace.nix b/configurations/darwin/aerospace.nix
@@ -0,0 +1,152 @@
+{ inputs, pkgs, ... }:
+
+let
+  std         = inputs.nix-std.lib;
+  newTerminal = pkgs.writeScript "newTerminalWindow.sh" ''
+    #!/usr/bin/env bash
+    # Open iTerm2 with single instance
+
+    # Detects if iTerm2 is running
+    if ! pgrep -f "iTerm" > /dev/null; then
+      open -a "${pkgs.iterm2}/Applications/iTerm2.app"
+    else
+      # Create a new window
+      if ! osascript -e 'tell application "iTerm2" to create window with default profile' > /dev/null; then
+        # Get pids for any app with "iTerm" and kill
+        for i in $(pgrep -f "iTerm"); do kill -15 "$i"; done
+        open  -a "${pkgs.iterm2}/Applications/iTerm2.app"
+      fi
+    fi
+  '';
+
+in {
+
+  homebrew = {
+    enable  = true;
+
+
+    casks = [
+       "nikitabobko/tap/aerospace"
+    ];
+  };
+
+  home-manager.users.leah.home.file.".aerospace.toml".text = (builtins.replaceStrings
+    [ "\"mode.main.binding\"" "\"mode.resize.binding\"" "\"if.app-id\"" "\"if.during-aerospace-startup\"" ]
+    [ "mode.main.binding"     "mode.resize.binding"     "if.app-id"     "if.during-aerospace-startup"]
+  (std.serde.toTOML {
+    enable-normalization-flatten-containers                         = false;
+    enable-normalization-opposite-orientation-for-nested-containers = false;
+
+    on-window-detected = [
+      {
+        "if.app-id" = "org.mozilla.firefox";
+        "run"       = [ "move-node-to-workspace 1" ];
+      }
+      {
+        "if.app-id" = "org.mozilla.thunderbird";
+        "run"       = [ "move-node-to-workspace 2" ];
+      }
+      {
+        "if.app-id"                   = "com.googlecode.iterm2";
+        "if.during-aerospace-startup" = true;
+        "run"                         = [ "move-node-to-workspace 3" ];
+      }
+      {
+        "if.app-id"                   = "com.apple.finder";
+        "if.during-aerospace-startup" = true;
+        "run"                         = [ "move-node-to-workspace 4" ];
+      }
+      {
+        "if.app-id" = "com.apple.iCal";
+        "run"       = [ "move-node-to-workspace 5" ];
+      }
+
+      {
+        "if.app-id"                   = "ru.keepcoder.Telegram";
+        "if.during-aerospace-startup" = true;
+        "run"                         = [ "layout floating" "move-node-to-workspace 1" ];
+      }
+      {
+        "if.app-id"                   = "com.jonny.mona";
+        "if.during-aerospace-startup" = true;
+        "run"                         = [ "layout floating" "move-node-to-workspace 1" ];
+      }
+
+    ];
+
+    "mode.main.binding" = {
+      "cmd-h"     = [];
+
+
+      "alt-enter" = "exec-and-forget ${newTerminal}";
+
+      "alt-z"     = "exec-and-forget pmset sleepnow";
+      "alt-x"     = "exec-and-forget pmset displaysleepnow";
+
+      "alt-left"  = "focus left";
+      "alt-right" = "focus right";
+      "alt-up"    = "focus up";
+      "alt-down"  = "focus down";
+
+      "alt-shift-left"  = "move left";
+      "alt-shift-right" = "move right";
+      "alt-shift-up"    = "move up";
+      "alt-shift-down"  = "move down";
+
+      # Consider using 'join-with' command as a 'split' replacement if you want to enable normalizations
+      "alt-h" = "split horizontal";
+      "alt-v" = "split vertical";
+
+      "alt-f" = "fullscreen";
+
+      "alt-s" = "layout v_accordion";               # 'layout stacking' in i3
+      "alt-w" = "layout h_accordion";               # 'layout tabbed' in i3
+      "alt-e" = "layout tiles horizontal vertical"; # 'layout toggle split' in i3
+
+      "alt-shift-space" = "layout floating tiling"; # 'floating toggle' in i3
+
+      # Not supported, because this command is redundant in AeroSpace mental model.
+      # See: https://nikitabobko.github.io/AeroSpace/guide#floating-windows
+      #alt-space = 'focus toggle_tiling_floating'
+
+      # `focus parent`/`focus child` are not yet supported, and it's not clear whether they
+      # should be supported at all https://github.com/nikitabobko/AeroSpace/issues/5
+      # alt-a = 'focus parent'
+
+      "alt-1" = "workspace 1";
+      "alt-2" = "workspace 2";
+      "alt-3" = "workspace 3";
+      "alt-4" = "workspace 4";
+      "alt-5" = "workspace 5";
+      "alt-6" = "workspace 6";
+      "alt-7" = "workspace 7";
+      "alt-8" = "workspace 8";
+      "alt-9" = "workspace 9";
+      "alt-0" = "workspace 10";
+
+      "alt-shift-1" = "move-node-to-workspace 1";
+      "alt-shift-2" = "move-node-to-workspace 2";
+      "alt-shift-3" = "move-node-to-workspace 3";
+      "alt-shift-4" = "move-node-to-workspace 4";
+      "alt-shift-5" = "move-node-to-workspace 5";
+      "alt-shift-6" = "move-node-to-workspace 6";
+      "alt-shift-7" = "move-node-to-workspace 7";
+      "alt-shift-8" = "move-node-to-workspace 8";
+      "alt-shift-9" = "move-node-to-workspace 9";
+      "alt-shift-0" = "move-node-to-workspace 10";
+
+      "alt-shift-c" = "reload-config";
+
+      "alt-r" = "mode resize";
+    };
+
+    "mode.resize.binding" = {
+      "h"     = "resize width -50";
+      "j"     = "resize height +50";
+      "k"     = "resize height -50";
+      "l"     = "resize width +50";
+      "enter" = "mode main";
+    };
+  }));
+
+}+
\ No newline at end of file
diff --git a/configurations/darwin/default.nix b/configurations/darwin/default.nix
@@ -11,6 +11,7 @@
     ./dock.nix
 
     ./skhd.nix
+    ./aerospace.nix
     ./syncthing.nix
     ./uhubDaemon.nix
     ./syncthing.nix