From bec2ab49e6286016c463b34bc50ac3f458fbb9a7 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 12 Feb 2026 10:53:08 +0000 Subject: [PATCH] Revert "darwin: switch from aerospace to PaperWM" This reverts commit cc074a561977be4c592feee86897276ebff36d40. --- hosts/darwin.nix | 4 - modules/home/aerospace/aerospace.toml | 200 ++++++++++++++++++ modules/home/aerospace/default.nix | 29 +++ .../home/aerospace/sketchybar/sketchybarrc | 82 +++++++ modules/home/hammerspoon/default.nix | 12 +- modules/home/hammerspoon/init.lua | 89 -------- modules/home/niri/config.kdl | 2 +- modules/home/profiles/desktop.nix | 1 + modules/system/focus-follows-mouse.nix | 31 --- 9 files changed, 319 insertions(+), 131 deletions(-) create mode 100644 modules/home/aerospace/aerospace.toml create mode 100644 modules/home/aerospace/default.nix create mode 100644 modules/home/aerospace/sketchybar/sketchybarrc delete mode 100644 modules/system/focus-follows-mouse.nix diff --git a/hosts/darwin.nix b/hosts/darwin.nix index 16f3120..16165e3 100644 --- a/hosts/darwin.nix +++ b/hosts/darwin.nix @@ -1,8 +1,4 @@ { - imports = [ - ../modules/system/focus-follows-mouse.nix - ]; - system.defaults.NSGlobalDomain.AppleFontSmoothing = 0; # https://tonsky.me/blog/monitors/ security.pam.services.sudo_local.touchIdAuth = true; diff --git a/modules/home/aerospace/aerospace.toml b/modules/home/aerospace/aerospace.toml new file mode 100644 index 0000000..1bace37 --- /dev/null +++ b/modules/home/aerospace/aerospace.toml @@ -0,0 +1,200 @@ +# Place a copy of this config to ~/.aerospace.toml +# After that, you can edit ~/.aerospace.toml to your liking + +# You can use it to add commands that run after login to macOS user session. +# 'start-at-login' needs to be 'true' for 'after-login-command' to work +# Available commands: https://nikitabobko.github.io/AeroSpace/commands +after-login-command = [] + +# You can use it to add commands that run after AeroSpace startup. +# 'after-startup-command' is run after 'after-login-command' +# Available commands : https://nikitabobko.github.io/AeroSpace/commands +after-startup-command = ['exec-and-forget sketchybar'] + +# Notify Sketchybar about workspace change +exec-on-workspace-change = ['/bin/bash', '-c', + 'sketchybar --trigger aerospace_workspace_change FOCUSED_WORKSPACE=$AEROSPACE_FOCUSED_WORKSPACE' +] + +# Start AeroSpace at login +start-at-login = true + +# Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization +enable-normalization-flatten-containers = true +enable-normalization-opposite-orientation-for-nested-containers = true + +# See: https://nikitabobko.github.io/AeroSpace/guide#layouts +# The 'accordion-padding' specifies the size of accordion padding +# You can set 0 to disable the padding feature +accordion-padding = 30 + +# Possible values: tiles|accordion +default-root-container-layout = 'tiles' + +# Possible values: horizontal|vertical|auto +# 'auto' means: wide monitor (anything wider than high) gets horizontal orientation, +# tall monitor (anything higher than wide) gets vertical orientation +default-root-container-orientation = 'auto' + +# Mouse follows focus when focused monitor changes +# Drop it from your config, if you don't like this behavior +# See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks +# See https://nikitabobko.github.io/AeroSpace/commands#move-mouse +# Fallback value (if you omit the key): on-focused-monitor-changed = [] +on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] + +# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag +# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key +# Also see: https://nikitabobko.github.io/AeroSpace/goodness#disable-hide-app +automatically-unhide-macos-hidden-apps = true + +# Possible values: (qwerty|dvorak) +# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping +[key-mapping] +preset = 'qwerty' + +# Gaps between windows (inner-*) and between monitor edges (outer-*). +# Possible values: +# - Constant: gaps.outer.top = 8 +# - Per monitor: gaps.outer.top = [{ monitor.main = 16 }, { monitor."some-pattern" = 32 }, 24] +# In this example, 24 is a default value when there is no match. +# Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. +# See: https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors +[gaps] +inner.horizontal = 8 +inner.vertical = 8 +outer.left = 8 +outer.bottom = 8 +outer.top = 8 +outer.right = 8 + +# 'main' binding mode declaration +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +# 'main' binding mode must be always presented +# Fallback value (if you omit the key): mode.main.binding = {} +[mode.main.binding] + +# All possible keys: +# - Letters. a, b, c, ..., z +# - Numbers. 0, 1, 2, ..., 9 +# - Keypad numbers. keypad0, keypad1, keypad2, ..., keypad9 +# - F-keys. f1, f2, ..., f20 +# - Special keys. minus, equal, period, comma, slash, backslash, quote, semicolon, backtick, +# leftSquareBracket, rightSquareBracket, space, enter, esc, backspace, tab +# - Keypad special. keypadClear, keypadDecimalMark, keypadDivide, keypadEnter, keypadEqual, +# keypadMinus, keypadMultiply, keypadPlus +# - Arrows. left, down, up, right + +# All possible modifiers: cmd, alt, ctrl, shift + +# All possible commands: https://nikitabobko.github.io/AeroSpace/commands + +# See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget +# Open up remote terminal with alt + enter shortcut +alt-enter = 'exec-and-forget wezterm connect arm.pc' + +# See: https://nikitabobko.github.io/AeroSpace/commands#layout +alt-slash = 'layout tiles horizontal vertical' +alt-comma = 'layout accordion horizontal vertical' + +# See: https://nikitabobko.github.io/AeroSpace/commands#focus +alt-h = 'focus left' +alt-j = 'focus down' +alt-k = 'focus up' +alt-l = 'focus right' + +# See: https://nikitabobko.github.io/AeroSpace/commands#move +alt-shift-h = 'move left' +alt-shift-j = 'move down' +alt-shift-k = 'move up' +alt-shift-l = 'move right' + +# See: https://nikitabobko.github.io/AeroSpace/commands#resize +alt-shift-minus = 'resize smart -50' +alt-shift-equal = 'resize smart +50' + +# See: https://nikitabobko.github.io/AeroSpace/commands#workspace +alt-1 = 'workspace 1' +alt-2 = 'workspace 2' +#alt-3 = 'workspace 3' # conflicts with '#' key on GB keyboard +alt-4 = 'workspace 4' +alt-5 = 'workspace 5' +alt-6 = 'workspace 6' +alt-7 = 'workspace 7' +alt-8 = 'workspace 8' +alt-9 = 'workspace 9' + +# See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace +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' + +# See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth +alt-tab = 'workspace-back-and-forth' +# See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor +alt-shift-tab = 'move-workspace-to-monitor --wrap-around next' + +# See: https://nikitabobko.github.io/AeroSpace/commands#mode +alt-shift-semicolon = 'mode service' + +# 'service' binding mode declaration. +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +[mode.service.binding] +esc = ['reload-config', 'mode main'] +r = ['flatten-workspace-tree', 'mode main'] # reset layout +f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout +backspace = ['close-all-windows-but-current', 'mode main'] + +# sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 +#s = ['layout sticky tiling', 'mode main'] + +alt-shift-h = ['join-with left', 'mode main'] +alt-shift-j = ['join-with down', 'mode main'] +alt-shift-k = ['join-with up', 'mode main'] +alt-shift-l = ['join-with right', 'mode main'] + +[[on-window-detected]] +if.app-id = "com.kagi.kagimacOS" +run = [ "move-node-to-workspace 1" ] + +[[on-window-detected]] +if.app-id = "app.zen-browser.zen" +run = [ "move-node-to-workspace 1" ] + +[[on-window-detected]] +if.app-id = "com.tinyspeck.slackmacgap" +run = [ "move-node-to-workspace 2" ] + +[[on-window-detected]] +if.app-id = "dev.vencord.vesktop" +run = [ "move-node-to-workspace 2" ] + +[[on-window-detected]] +if.app-id = "com.microsoft.VSCode" +run = [ "move-node-to-workspace 4" ] + +[[on-window-detected]] +if.app-id = "md.obsidian" +run = [ "move-node-to-workspace 7" ] + +[[on-window-detected]] +if.app-id = "com.TickTick.task.mac" +run = [ "move-node-to-workspace 8" ] + +[[on-window-detected]] +if.app-id = "com.spotify.client" +run = [ "move-node-to-workspace 9" ] + +[[on-window-detected]] +if.app-id = "com.kagi.kagimacOS.WebApp.758E8559-F3A6-4B80-B34E-901673F85285" # SoundCloud +run = [ "move-node-to-workspace 9" ] + +[[on-window-detected]] +if.window-title-regex-substring = "Cisco Secure Client" +run = [ "layout floating" ] diff --git a/modules/home/aerospace/default.nix b/modules/home/aerospace/default.nix new file mode 100644 index 0000000..ef489a3 --- /dev/null +++ b/modules/home/aerospace/default.nix @@ -0,0 +1,29 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + config = lib.mkIf config.isMacOS { + home.packages = [ + pkgs.aerospace + #pkgs.sketchybar + ]; + home.file.".config/aerospace/aerospace.toml".source = ./aerospace.toml; + launchd.agents.aerospace = { + enable = true; + config = { + Program = "${pkgs.aerospace}/Applications/AeroSpace.app/Contents/MacOS/AeroSpace"; + KeepAlive = true; + RunAtLoad = true; + StandardOutPath = "/tmp/aerospace.log"; + StandardErrorPath = "/tmp/aerospace.err.log"; + }; + }; + + #home.file.".config/sketchybar/sketchybarrc" = { source = ./sketchybar/sketchybarrc; executable = true; }; + #home.file.".config/sketchybar/plugins".source = ./sketchybar/plugins; + #home.file.".config/sketchybar/plugins".recursive = true; + }; +} diff --git a/modules/home/aerospace/sketchybar/sketchybarrc b/modules/home/aerospace/sketchybar/sketchybarrc new file mode 100644 index 0000000..6bb7f79 --- /dev/null +++ b/modules/home/aerospace/sketchybar/sketchybarrc @@ -0,0 +1,82 @@ +# This is a demo config to showcase some of the most important commands. +# It is meant to be changed and configured, as it is intentionally kept sparse. +# For a (much) more advanced configuration example see my dotfiles: +# https://github.com/FelixKratz/dotfiles + +PLUGIN_DIR="$CONFIG_DIR/plugins" + +##### Bar Appearance ##### +# Configuring the general appearance of the bar. +# These are only some of the options available. For all options see: +# https://felixkratz.github.io/SketchyBar/config/bar +# If you are looking for other colors, see the color picker: +# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker + +sketchybar --bar position=top height=38 blur_radius=30 color=0x40000000 + +##### Changing Defaults ##### +# We now change some default values, which are applied to all further items. +# For a full list of all available item properties see: +# https://felixkratz.github.io/SketchyBar/config/items + +default=( + padding_left=5 + padding_right=5 + icon.font="Hack Nerd Font:Bold:17.0" + label.font="Hack Nerd Font:Bold:14.0" + icon.color=0xffffffff + label.color=0xffffffff + icon.padding_left=4 + icon.padding_right=4 + label.padding_left=4 + label.padding_right=4 +) +sketchybar --default "${default[@]}" + +##### Aerospace Workspaces ##### +sketchybar --add event aerospace_workspace_change + +for sid in $(aerospace list-workspaces --all); do + sketchybar --add item space.$sid left \ + --subscribe space.$sid aerospace_workspace_change \ + --set space.$sid \ + background.color=0x44ffffff \ + background.corner_radius=5 \ + background.height=20 \ + background.drawing=off \ + label="$sid" \ + click_script="aerospace workspace $sid" +done + +##### Adding Left Items ##### +# We add some regular items to the left side of the bar, where +# only the properties deviating from the current defaults need to be set + +# sketchybar --add item chevron left \ +# --set chevron icon= label.drawing=off \ +# --add item front_app left \ +# --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ +# --subscribe front_app front_app_switched + +##### Adding Right Items ##### +# In the same way as the left items we can add items to the right side. +# Additional position (e.g. center) are available, see: +# https://felixkratz.github.io/SketchyBar/config/items#adding-items-to-sketchybar + +# Some items refresh on a fixed cycle, e.g. the clock runs its script once +# every 10s. Other items respond to events they subscribe to, e.g. the +# volume.sh script is only executed once an actual change in system audio +# volume is registered. More info about the event system can be found here: +# https://felixkratz.github.io/SketchyBar/config/events + +# sketchybar --add item clock right \ +# --set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \ +# --add item volume right \ +# --set volume script="$PLUGIN_DIR/volume.sh" \ +# --subscribe volume volume_change \ +# --add item battery right \ +# --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ +# --subscribe battery system_woke power_source_change + +##### Force all scripts to run the first time (never do this in a script) ##### +sketchybar --update diff --git a/modules/home/hammerspoon/default.nix b/modules/home/hammerspoon/default.nix index d1c04de..8a4e785 100644 --- a/modules/home/hammerspoon/default.nix +++ b/modules/home/hammerspoon/default.nix @@ -15,12 +15,12 @@ enable = true; configPath = ./init.lua; spoons = { - PaperWM = pkgs.fetchFromGitHub { - owner = "mogenson"; - repo = "PaperWM.spoon"; - rev = "41c796a7edd78575aa71b77295672aa0a4a2c3ea"; - sha256 = "0ryck3d6p0rb3zf7wgn83rfn5dqjw98fpbr1cw83jly44sn6d9mv"; - }; + # PaperWM = pkgs.fetchFromGitHub { + # owner = "mogenson"; + # repo = "PaperWM.spoon"; + # rev = "41c796a7edd78575aa71b77295672aa0a4a2c3ea"; + # sha256 = "0ryck3d6p0rb3zf7wgn83rfn5dqjw98fpbr1cw83jly44sn6d9mv"; + # }; AutoMuteOnSleep = pkgs.fetchzip { url = "https://github.com/Hammerspoon/Spoons/raw/master/Spoons/AutoMuteOnSleep.spoon.zip"; sha256 = "13llr8j6iwbd5wvsg9mzmzxz06xsnl6mq83bgbnkyk5jbqhzcvxm"; diff --git a/modules/home/hammerspoon/init.lua b/modules/home/hammerspoon/init.lua index 7e47140..288c4a7 100644 --- a/modules/home/hammerspoon/init.lua +++ b/modules/home/hammerspoon/init.lua @@ -1,90 +1 @@ -PaperWM = hs.loadSpoon("PaperWM") - --- Match niri layout settings -PaperWM.window_gap = 16 -PaperWM.window_ratios = { 1 / 3, 1 / 2, 2 / 3 } - -PaperWM.swipe_fingers = 3 -PaperWM.lift_window = { "alt", "cmd", "shift" } - --- Niri-like keybindings --- Niri uses Mod (Super) as the primary modifier. On macOS, cmd is taken by --- system shortcuts so we use alt as the equivalent of niri's Mod. --- --- Niri PaperWM --- Mod+H/J/K/L -> alt+H/J/K/L focus --- Mod+Ctrl+H/J/K/L -> alt+ctrl+H/J/K/L move/swap --- Mod+R -> alt+R cycle width --- Mod+Shift+R -> alt+shift+R cycle height --- Mod+F -> alt+F full width --- Mod+C -> alt+C center --- Mod+V -> alt+V toggle floating --- Mod+[ / Mod+] -> alt+[ / alt+] slurp/barf (consume/expel) --- Mod+- / Mod+= -> alt+- / alt+= decrease/increase width --- Mod+1-9 -> alt+1-9 switch space --- Mod+Ctrl+1-9 -> alt+ctrl+1-9 move window to space - -PaperWM:bindHotkeys({ - -- Focus (niri: Mod+H/J/K/L and Mod+Arrows) - focus_left = { { "alt" }, "h" }, - focus_down = { { "alt" }, "j" }, - focus_up = { { "alt" }, "k" }, - focus_right = { { "alt" }, "l" }, - - -- Swap/move (niri: Mod+Ctrl+H/J/K/L and Mod+Ctrl+Arrows) - swap_left = { { "alt", "ctrl" }, "h" }, - swap_down = { { "alt", "ctrl" }, "j" }, - swap_up = { { "alt", "ctrl" }, "k" }, - swap_right = { { "alt", "ctrl" }, "l" }, - - -- Width cycling (niri: Mod+R / Ctrl+Mod+R) - cycle_width = { { "alt" }, "r" }, - reverse_cycle_width = { { "alt", "ctrl" }, "r" }, - - -- Height cycling (niri: Mod+Shift+R / Ctrl+Mod+Shift+R) - cycle_height = { { "alt", "shift" }, "r" }, - reverse_cycle_height = { { "alt", "ctrl", "shift" }, "r" }, - - -- Width adjustments (niri: Mod+Minus / Mod+Equal) - decrease_width = { { "alt" }, "-" }, - increase_width = { { "alt" }, "=" }, - - -- Full width (niri: Mod+F) - full_width = { { "alt" }, "f" }, - - -- Center (niri: Mod+C) - center_window = { { "alt" }, "c" }, - - -- Toggle floating (niri: Mod+V) - toggle_floating = { { "alt" }, "v" }, - - -- Slurp/barf (niri: Mod+[ consume, Mod+] expel) - slurp_in = { { "alt" }, "[" }, - barf_out = { { "alt" }, "]" }, - - -- Switch space (niri: Mod+1-9) - switch_space_1 = { { "alt" }, "1" }, - switch_space_2 = { { "alt" }, "2" }, - switch_space_3 = { { "alt" }, "3" }, - switch_space_4 = { { "alt" }, "4" }, - switch_space_5 = { { "alt" }, "5" }, - switch_space_6 = { { "alt" }, "6" }, - switch_space_7 = { { "alt" }, "7" }, - switch_space_8 = { { "alt" }, "8" }, - switch_space_9 = { { "alt" }, "9" }, - - -- Move window to space (niri: Mod+Ctrl+1-9) - move_window_1 = { { "alt", "ctrl" }, "1" }, - move_window_2 = { { "alt", "ctrl" }, "2" }, - move_window_3 = { { "alt", "ctrl" }, "3" }, - move_window_4 = { { "alt", "ctrl" }, "4" }, - move_window_5 = { { "alt", "ctrl" }, "5" }, - move_window_6 = { { "alt", "ctrl" }, "6" }, - move_window_7 = { { "alt", "ctrl" }, "7" }, - move_window_8 = { { "alt", "ctrl" }, "8" }, - move_window_9 = { { "alt", "ctrl" }, "9" }, -}) - -PaperWM:start() - hs.loadSpoon("AutoMuteOnSleep") diff --git a/modules/home/niri/config.kdl b/modules/home/niri/config.kdl index 64cd73b..257a3eb 100644 --- a/modules/home/niri/config.kdl +++ b/modules/home/niri/config.kdl @@ -58,7 +58,7 @@ input { } // Uncomment this to make the mouse warp to the center of newly focused windows. - warp-mouse-to-focus + //warp-mouse-to-focus // Focus windows and outputs automatically when moving the mouse into them. // Setting max-scroll-amount="0%" makes it work only on windows already fully on screen. diff --git a/modules/home/profiles/desktop.nix b/modules/home/profiles/desktop.nix index b86ff37..38b9ee1 100644 --- a/modules/home/profiles/desktop.nix +++ b/modules/home/profiles/desktop.nix @@ -21,6 +21,7 @@ in ./headless.nix ../gl.nix ../niri + ../aerospace ../hammerspoon ../ghostty ../zed.nix diff --git a/modules/system/focus-follows-mouse.nix b/modules/system/focus-follows-mouse.nix deleted file mode 100644 index 38b8854..0000000 --- a/modules/system/focus-follows-mouse.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -let - autoraise = pkgs.autoraise.overrideAttrs (old: { - buildPhase = '' - runHook preBuild - $CXX -std=c++03 -fobjc-arc -D"NS_FORMAT_ARGUMENT(A)=" -D"SKYLIGHT_AVAILABLE=1" -DEXPERIMENTAL_FOCUS_FIRST -o AutoRaise AutoRaise.mm -framework AppKit -framework SkyLight - bash create-app-bundle.sh - runHook postBuild - ''; - }); -in -{ - config = lib.mkIf pkgs.stdenv.isDarwin { - environment.systemPackages = [ autoraise ]; - - launchd.user.agents.autoraise = { - command = "${autoraise}/bin/autoraise -delay 0 -focusDelay 1"; - serviceConfig = { - KeepAlive = true; - RunAtLoad = true; - StandardOutPath = "/tmp/autoraise.log"; - StandardErrorPath = "/tmp/autoraise.err.log"; - }; - }; - }; -} -- 2.51.2