From e8b184b4aeae0077c7ce1540a4b5c71479440839 Mon Sep 17 00:00:00 2001 From: Random936 Date: Fri, 1 Nov 2024 21:53:46 -0700 Subject: [PATCH] Switching from yabai to aerospace; moved module nix files to directory --- config/darwin.nix | 93 ++-------------------------------- home/darwin.nix | 7 +-- home/headful-nixos.nix | 8 +-- home/headless-nixos.nix | 4 +- home/modules/aerospace.nix | 88 ++++++++++++++++++++++++++++++++ home/{ => modules}/emacs.nix | 16 +++--- home/{ => modules}/hacking.nix | 0 home/{ => modules}/neovim.nix | 0 home/{ => modules}/zsh.nix | 4 +- 9 files changed, 112 insertions(+), 108 deletions(-) create mode 100644 home/modules/aerospace.nix rename home/{ => modules}/emacs.nix (60%) rename home/{ => modules}/hacking.nix (100%) rename home/{ => modules}/neovim.nix (100%) rename home/{ => modules}/zsh.nix (96%) diff --git a/config/darwin.nix b/config/darwin.nix index f6a37cd..1af6978 100644 --- a/config/darwin.nix +++ b/config/darwin.nix @@ -12,6 +12,9 @@ homebrew = { enable = true; onActivation.cleanup = "zap"; + taps = [ + "nikitabobko/tap" + ]; brews = [ "wireguard-tools" "bitwarden-cli" @@ -22,6 +25,7 @@ "scroll-reverser" "google-chrome" "instantview" + "aerospace" "bitwarden" "tailscale" "discord" @@ -59,94 +63,5 @@ home = "/Users/jadenmaxwell"; }; - # Window Manager - services.skhd = { - enable = true; - skhdConfig = '' - # Config intended for use with Yabai on MacOS - - # Switching Window Focus - cmd - h : yabai -m window --focus west - cmd - j : yabai -m window --focus south - cmd - k : yabai -m window --focus north - cmd - l : yabai -m window --focus east - - # Swap Windows - shift + cmd - h : yabai -m window --swap west - shift + cmd - j : yabai -m window --swap south - shift + cmd - k : yabai -m window --swap north - shift + cmd - l : yabai -m window --swap east - - # Focus on Space # - cmd - 1 : yabai -m space --focus 1 - cmd - 2 : yabai -m space --focus 2 - cmd - 3 : yabai -m space --focus 3 - cmd - 4 : yabai -m space --focus 4 - cmd - 5 : yabai -m space --focus 5 - cmd - 6 : yabai -m space --focus 6 - cmd - 7 : yabai -m space --focus 7 - cmd - 8 : yabai -m space --focus 8 - cmd - 9 : yabai -m space --focus 9 - - # Move Window to Space # - shift + cmd - 1 : yabai -m window --space 1 - shift + cmd - 2 : yabai -m window --space 2 - shift + cmd - 3 : yabai -m window --space 3 - shift + cmd - 4 : yabai -m window --space 4 - shift + cmd - 5 : yabai -m window --space 5 - shift + cmd - 6 : yabai -m window --space 6 - shift + cmd - 7 : yabai -m window --space 7 - shift + cmd - 8 : yabai -m window --space 8 - shift + cmd - 9 : yabai -m window --space 9 - - # Toggle window split - cmd - e : yabai -m window --toggle split - - # Full Screen Window - cmd - f : yabai -m window --toggle zoom-fullscreen - alt - f : osascript -e 'tell application "System Events" to set frontApp to name of first application process whose frontmost is true' \ - -e 'tell application "System Events" to tell process frontApp to click menu item "Find…" of menu 1 of menu item "Find" of menu "Edit" of menu bar item "Edit" of menu bar 1' - - # Close window with i3 keybinding - cmd - q : yabai -m window --close - - # Close space - shift + cmd - w : yabai -m space --destroy - - # Application shortcuts - shift + cmd - e : emacs - shift + cmd - f : open -n -a "Google Chrome" - shift + cmd - d : open -n -a "Discord" - cmd - return : osascript -e 'tell application "iTerm2" to create window with default profile' - - # Reload skhd config - shift + cmd - r : ${pkgs.skhd}/bin/skhd -r - ''; - }; - - services.yabai = { - enable = true; - enableScriptingAddition = true; - - config = { - layout = "bsp"; - mouse_follows_focus = "on"; - focus_follows_mouse = "autoraise"; - window_placement = "second_child"; - auto_balance = "on"; - mouse_modifier = "fn"; - mouse_action1 = "move"; - mouse_action2 = "resize"; - }; - - extraConfig = '' - yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - yabai -m signal --add event=application_terminated action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse" - yabai -m rule --add app="^System Settings$" manage=off - yabai -m rule --add app="^Calculator$" manage=off - yabai -m rule --add app="^iPhone Mirroring$" manage=off - ''; - }; - system.stateVersion = 4; } diff --git a/home/darwin.nix b/home/darwin.nix index 703e961..cc88167 100644 --- a/home/darwin.nix +++ b/home/darwin.nix @@ -10,8 +10,9 @@ imports = [ ./shared.nix - ./neovim.nix - ./emacs.nix - ./zsh.nix + ./modules/aerospace.nix + ./modules/neovim.nix + ./modules/emacs.nix + ./modules/zsh.nix ]; } diff --git a/home/headful-nixos.nix b/home/headful-nixos.nix index 703678d..bf8b820 100644 --- a/home/headful-nixos.nix +++ b/home/headful-nixos.nix @@ -7,10 +7,10 @@ imports = [ ./shared.nix - ./hacking.nix - ./neovim.nix - ./emacs.nix - ./zsh.nix + ./modules/hacking.nix + ./modules/neovim.nix + ./modules/emacs.nix + ./modules/zsh.nix ]; home.packages = with pkgs; [ diff --git a/home/headless-nixos.nix b/home/headless-nixos.nix index 3742891..2bb3296 100644 --- a/home/headless-nixos.nix +++ b/home/headless-nixos.nix @@ -7,8 +7,8 @@ imports = [ ./shared.nix - ./neovim.nix - ./zsh.nix + ./modules/neovim.nix + ./modules/zsh.nix ]; home.packages = with pkgs; [ diff --git a/home/modules/aerospace.nix b/home/modules/aerospace.nix new file mode 100644 index 0000000..c1682ed --- /dev/null +++ b/home/modules/aerospace.nix @@ -0,0 +1,88 @@ +{ ... }: { + home.file.".aerospace.toml".text = '' + # Reference: https://github.com/i3/i3/blob/next/etc/config + # i3 doesn't have "normalizations" feature that why we disable them here. + # But the feature is very helpful. + # Normalizations eliminate all sorts of weird tree configurations that don't make sense. + # Give normalizations a chance and enable them back. + enable-normalization-flatten-containers = false + enable-normalization-opposite-orientation-for-nested-containers = false + + # Mouse follows focus when focused monitor changes + on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] + + [mode.main.binding] + # See: https://nikitabobko.github.io/AeroSpace/goodness#open-a-new-window-with-applescript + alt-enter = '''exec-and-forget osascript -e ' + tell application "Terminal" + do script + activate + end tell' + ''' + + # i3 wraps focus by default + alt-j = 'focus --boundaries-action wrap-around-the-workspace left' + alt-k = 'focus --boundaries-action wrap-around-the-workspace down' + alt-l = 'focus --boundaries-action wrap-around-the-workspace up' + alt-semicolon = 'focus --boundaries-action wrap-around-the-workspace right' + + alt-shift-j = 'move left' + alt-shift-k = 'move down' + alt-shift-l = 'move up' + alt-shift-semicolon = 'move right' + + # 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' + esc = 'mode main' + ''; +} diff --git a/home/emacs.nix b/home/modules/emacs.nix similarity index 60% rename from home/emacs.nix rename to home/modules/emacs.nix index c75cdff..c3edc4f 100644 --- a/home/emacs.nix +++ b/home/modules/emacs.nix @@ -44,13 +44,13 @@ }; home.file = { - ".emacs".source = ../dotfiles/.emacs; - ".emacs.d/config.org".source = ../dotfiles/.emacs.d/config.org; - ".emacs.d/terminal.org".source = ../dotfiles/.emacs.d/terminal.org; - ".emacs.d/functions.org".source = ../dotfiles/.emacs.d/functions.org; - ".emacs.d/email.org".source = ../dotfiles/.emacs.d/email.org; - ".emacs.d/org.org".source = ../dotfiles/.emacs.d/org.org; - ".emacs.d/lsp.org".source = ../dotfiles/.emacs.d/lsp.org; - ".mbsyncrc".source = ../dotfiles/.mbsyncrc; + ".emacs".source = ../../dotfiles/.emacs; + ".emacs.d/config.org".source = ../../dotfiles/.emacs.d/config.org; + ".emacs.d/terminal.org".source = ../../dotfiles/.emacs.d/terminal.org; + ".emacs.d/functions.org".source = ../../dotfiles/.emacs.d/functions.org; + ".emacs.d/email.org".source = ../../dotfiles/.emacs.d/email.org; + ".emacs.d/org.org".source = ../../dotfiles/.emacs.d/org.org; + ".emacs.d/lsp.org".source = ../../dotfiles/.emacs.d/lsp.org; + ".mbsyncrc".source = ../../dotfiles/.mbsyncrc; }; } diff --git a/home/hacking.nix b/home/modules/hacking.nix similarity index 100% rename from home/hacking.nix rename to home/modules/hacking.nix diff --git a/home/neovim.nix b/home/modules/neovim.nix similarity index 100% rename from home/neovim.nix rename to home/modules/neovim.nix diff --git a/home/zsh.nix b/home/modules/zsh.nix similarity index 96% rename from home/zsh.nix rename to home/modules/zsh.nix index d78417a..b36395b 100644 --- a/home/zsh.nix +++ b/home/modules/zsh.nix @@ -49,12 +49,12 @@ plugins = [ { name = "custom-functions"; - src = ../dotfiles; + src = ../../dotfiles; file = ".functions.zsh"; } { name = "powerlevel10k-config"; - src = ../dotfiles; + src = ../../dotfiles; file = ".p10k.zsh"; } ];