mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-21 17:09:46 +01:00
feat(darwin): migrate to aerospace
This commit is contained in:
197
home/darwin/aerospace/aerospace.toml
Normal file
197
home/darwin/aerospace/aerospace.toml
Normal file
@@ -0,0 +1,197 @@
|
||||
# Place a copy of this config to ~/.aerospace.toml
|
||||
# After that, you can edit ~/.aerospace.toml to your liking
|
||||
|
||||
# It's not necessary to copy all keys to your config.
|
||||
# If the key is missing in your config, "default-config.toml" will serve as a fallback
|
||||
|
||||
# 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 = []
|
||||
|
||||
# Start AeroSpace at login
|
||||
start-at-login = false
|
||||
|
||||
# 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'
|
||||
|
||||
# Possible values: (qwerty|dvorak)
|
||||
# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping
|
||||
key-mapping.preset = 'qwerty'
|
||||
|
||||
# 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
|
||||
on-focused-monitor-changed = ['move-mouse monitor-lazy-center']
|
||||
|
||||
# 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 = 0
|
||||
inner.vertical = 0
|
||||
outer.left = 0
|
||||
outer.bottom = 0
|
||||
outer.top = 0
|
||||
outer.right = 0
|
||||
|
||||
# 'main' binding mode declaration
|
||||
# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes
|
||||
# 'main' binding mode must be always presented
|
||||
[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
|
||||
# You can uncomment the following lines to open up terminal with alt + enter shortcut (like in i3)
|
||||
# alt-enter = '''exec-and-forget osascript -e '
|
||||
# tell application "Terminal"
|
||||
# do script
|
||||
# activate
|
||||
# end tell'
|
||||
# '''
|
||||
|
||||
# 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'
|
||||
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-a = 'workspace A' # In your config, you can drop workspace bindings that you don't need
|
||||
alt-b = 'workspace B'
|
||||
alt-c = 'workspace C'
|
||||
alt-d = 'workspace D'
|
||||
alt-e = 'workspace E'
|
||||
alt-f = 'workspace F'
|
||||
alt-g = 'workspace G'
|
||||
alt-i = 'workspace I'
|
||||
alt-m = 'workspace M'
|
||||
alt-n = 'workspace N'
|
||||
alt-o = 'workspace O'
|
||||
alt-p = 'workspace P'
|
||||
alt-q = 'workspace Q'
|
||||
alt-r = 'workspace R'
|
||||
alt-s = 'workspace S'
|
||||
alt-t = 'workspace T'
|
||||
alt-u = 'workspace U'
|
||||
alt-v = 'workspace V'
|
||||
alt-w = 'workspace W'
|
||||
alt-x = 'workspace X'
|
||||
alt-y = 'workspace Y'
|
||||
alt-z = 'workspace Z'
|
||||
|
||||
# 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'
|
||||
alt-shift-a = 'move-node-to-workspace A'
|
||||
alt-shift-b = 'move-node-to-workspace B'
|
||||
alt-shift-c = 'move-node-to-workspace C'
|
||||
alt-shift-d = 'move-node-to-workspace D'
|
||||
alt-shift-e = 'move-node-to-workspace E'
|
||||
alt-shift-f = 'move-node-to-workspace F'
|
||||
alt-shift-g = 'move-node-to-workspace G'
|
||||
alt-shift-i = 'move-node-to-workspace I'
|
||||
alt-shift-m = 'move-node-to-workspace M'
|
||||
alt-shift-n = 'move-node-to-workspace N'
|
||||
alt-shift-o = 'move-node-to-workspace O'
|
||||
alt-shift-p = 'move-node-to-workspace P'
|
||||
alt-shift-q = 'move-node-to-workspace Q'
|
||||
alt-shift-r = 'move-node-to-workspace R'
|
||||
alt-shift-s = 'move-node-to-workspace S'
|
||||
alt-shift-t = 'move-node-to-workspace T'
|
||||
alt-shift-u = 'move-node-to-workspace U'
|
||||
alt-shift-v = 'move-node-to-workspace V'
|
||||
alt-shift-w = 'move-node-to-workspace W'
|
||||
alt-shift-x = 'move-node-to-workspace X'
|
||||
alt-shift-y = 'move-node-to-workspace Y'
|
||||
alt-shift-z = 'move-node-to-workspace Z'
|
||||
|
||||
# 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
|
||||
#s = ['layout sticky tiling', 'mode main'] # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2
|
||||
f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout
|
||||
backspace = ['close-all-windows-but-current', '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']
|
||||
3
home/darwin/aerospace/default.nix
Normal file
3
home/darwin/aerospace/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
home.file.".aerospace.toml".source = ./aerospace.toml;
|
||||
}
|
||||
@@ -114,6 +114,7 @@ in {
|
||||
"homebrew/cask-versions"
|
||||
|
||||
"hashicorp/tap"
|
||||
"nikitabobko/tap"
|
||||
];
|
||||
|
||||
brews = [
|
||||
@@ -151,6 +152,7 @@ in {
|
||||
"google-chrome"
|
||||
"visual-studio-code"
|
||||
"zed" # zed editor
|
||||
"aerospace" # an i3-like tiling window manager for macOS
|
||||
|
||||
# https://joplinapp.org/help/
|
||||
"joplin" # note taking app
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
config,
|
||||
myvars,
|
||||
...
|
||||
}: {
|
||||
services.skhd = {
|
||||
enable = true;
|
||||
skhdConfig = builtins.readFile ./skhdrc;
|
||||
};
|
||||
|
||||
# custom log path for debugging
|
||||
launchd.user.agents.skhd.serviceConfig = let
|
||||
homeDir = config.users.users."${myvars.username}".home;
|
||||
in {
|
||||
StandardErrorPath = "${homeDir}/Library/Logs/skhd.stderr.log";
|
||||
StandardOutPath = "${homeDir}/Library/Logs/skhd.stdout.log";
|
||||
};
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
# https://github.com/koekeishiya/yabai/blob/master/examples/skhdrc
|
||||
#
|
||||
# 配置语法 : <modifier> - <key> : <command>
|
||||
# modifier 可以是单个键比如 cmd, alt, ctrl, 也可以是组合键比如 ctrl + shift, ctrl + alt
|
||||
# ================================ 打开终端 ================================
|
||||
# 启动终端
|
||||
cmd - return : open -a kitty
|
||||
# 关闭当前窗口,这个不需要加,macOS 默认是 cmd + q,我 Linux 也这么设置的
|
||||
# ================================ 窗口设置 ================================
|
||||
# =============== 为了避免快捷键冲突改用了 ctrl 作为 modifier =================
|
||||
# https://github.com/koekeishiya/yabai/wiki/Commands
|
||||
# 切换为平铺模式
|
||||
alt - e : yabai -m space --layout bsp
|
||||
# 切换为堆叠模式
|
||||
alt - s : yabai -m space --layout stack
|
||||
# 浮动/不浮动窗口 float
|
||||
alt - f : yabai -m window --toggle float
|
||||
# 全屏
|
||||
cmd + alt - f : yabai -m window --toggle zoom-fullscreen
|
||||
|
||||
# focus window : 激活窗口快捷键 h: 左 j: 下 k: 右 l: 上
|
||||
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
|
||||
|
||||
# 调整窗口大小
|
||||
ctrl + alt + cmd - left : yabai -m window --resize left:-50:0; yabai -m window --resize right:-50:0
|
||||
ctrl + alt + cmd - down : yabai -m window --resize bottom:0:50; yabai -m window --resize top:0:50
|
||||
ctrl + alt + cmd - up : yabai -m window --resize top:0:-50; yabai -m window --resize bottom:0:-50
|
||||
ctrl + alt + cmd - right : yabai -m window --resize right:50:0; yabai -m window --resize left:50:0
|
||||
|
||||
# ================================ 多桌面配置 ================================
|
||||
# 创建一个新桌面,并把当前活动的窗口发送到新桌面,并且自动跳转到新桌面. 需要 jq 支持 brew install jq
|
||||
shift + cmd - n : yabai -m space --create && index="$(yabai -m query --spaces --display | jq '.| length')" && yabai -m window --space "${index}" && yabai -m space --focus "${index}" && yabai -m space --layout bsp
|
||||
|
||||
# 在 stack 模式下通过方向键切换窗口
|
||||
ctrl - down : yabai -m window --focus stack.next || yabai -m window --focus south
|
||||
ctrl - up : yabai -m window --focus stack.prev || yabai -m window --focus north
|
||||
# 在 bsp 模式下通过方向键切换窗口
|
||||
cmd - left : yabai -m window --focus west
|
||||
cmd - right : yabai -m window --focus east
|
||||
|
||||
# 切换回最近的一个桌面
|
||||
alt - r : yabai -m space --focus recent
|
||||
# 在 9 个桌面之间切换
|
||||
alt - 1 : yabai -m space --focus 1
|
||||
alt - 2 : yabai -m space --focus 2
|
||||
alt - 3 : yabai -m space --focus 3
|
||||
alt - 4 : yabai -m space --focus 4
|
||||
alt - 5 : yabai -m space --focus 5
|
||||
alt - 6 : yabai -m space --focus 6
|
||||
alt - 7 : yabai -m space --focus 7
|
||||
alt - 8 : yabai -m space --focus 8
|
||||
alt - 9 : yabai -m space --focus 9
|
||||
# 关闭当前桌面
|
||||
cmd + alt - w : yabai -m space --destroy
|
||||
# 把窗口发送到桌面,并跟随过去 send window to desktop and follow focus
|
||||
shift + cmd - z : yabai -m window --space next; yabai -m space --focus next
|
||||
shift + cmd - 1 : yabai -m window --space 1; yabai -m space --focus 1
|
||||
shift + cmd - 2 : yabai -m window --space 2; yabai -m space --focus 2
|
||||
shift + cmd - 3 : yabai -m window --space 3; yabai -m space --focus 3
|
||||
shift + cmd - 4 : yabai -m window --space 4; yabai -m space --focus 4
|
||||
shift + cmd - 5 : yabai -m window --space 5; yabai -m space --focus 5
|
||||
shift + cmd - 6 : yabai -m window --space 6; yabai -m space --focus 6
|
||||
shift + cmd - 7 : yabai -m window --space 7; yabai -m space --focus 7
|
||||
shift + cmd - 8 : yabai -m window --space 8; yabai -m space --focus 8
|
||||
shift + cmd - 9 : yabai -m window --space 9; yabai -m space --focus 9
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{
|
||||
config,
|
||||
myvars,
|
||||
...
|
||||
}: let
|
||||
homeDir = config.users.users."${myvars.username}".home;
|
||||
in {
|
||||
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/ya/yabai/package.nix
|
||||
services.yabai = {
|
||||
enable = true;
|
||||
|
||||
# Whether to enable yabai's scripting-addition.
|
||||
# SIP must be disabled for this to work.
|
||||
# https://github.com/koekeishiya/yabai/wiki/Disabling-System-Integrity-Protection
|
||||
enableScriptingAddition = true;
|
||||
# config = {};
|
||||
extraConfig = builtins.readFile ./yabairc;
|
||||
};
|
||||
|
||||
# custom log path for debugging
|
||||
launchd.user.agents.yabai.serviceConfig = {
|
||||
StandardErrorPath = "${homeDir}/Library/Logs/yabai.stderr.log";
|
||||
StandardOutPath = "${homeDir}/Library/Logs/yabai.stdout.log";
|
||||
};
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# wiki 要求在配置最前面加这个,看起来是跟 sudo 权限相关的东西
|
||||
sudo yabai --load-sa
|
||||
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
|
||||
|
||||
## 输出 debug 日志,出问题时方便排查
|
||||
yabai -m config debug_output on
|
||||
|
||||
# 窗口平铺
|
||||
yabai -m space --layout bsp
|
||||
# 默认拆分规则 first_child second_child
|
||||
yabai -m config window_placement second_child
|
||||
# 窗口间距设置
|
||||
yabai -m config top_padding 10
|
||||
yabai -m config bottom_padding 10
|
||||
yabai -m config left_padding 10
|
||||
yabai -m config right_padding 10
|
||||
yabai -m config window_gap 10
|
||||
# 自动平衡所有窗口始终占据相同的空间
|
||||
yabai -m config auto_balance off
|
||||
# 如果禁用自动平衡,此项属性定义的是新窗口占用的空间量。0.5意为旧窗口占用50%
|
||||
yabai -m config split_ratio 0.50
|
||||
# 鼠标修饰键 意思就是按着这个键就可以使用鼠标单独修改窗口大小了
|
||||
yabai -m config mouse_modifier ctrl
|
||||
# ctrl + 鼠标左键 移动窗口
|
||||
yabai -m config mouse_action1 move
|
||||
# ctrl + 鼠标右键 调整窗口大小
|
||||
yabai -m config mouse_action2 resize
|
||||
# 焦点跟随鼠标 默认off: 关闭 autoraise:自动提升 autofocus: 自动对焦
|
||||
yabai -m config focus_follows_mouse autofocus
|
||||
# 设置鼠标是否跟随当前活动窗口 默认 off: 关闭 on: 开启
|
||||
yabai -m config mouse_follows_focus on
|
||||
|
||||
# 修改窗口阴影 on: 打开 off: 关闭 float: 只显示浮动窗口的阴影
|
||||
yabai -m config window_shadow float
|
||||
|
||||
# 窗口透明度设置
|
||||
yabai -m config window_opacity on
|
||||
# 配置活动窗口不透明度
|
||||
yabai -m config active_window_opacity 0.98
|
||||
yabai -m config normal_window_opacity 0.9
|
||||
yabai -m config window_opacity_duration 0.0
|
||||
|
||||
|
||||
# 在所有显示器上的每个空间顶部添加 0 填充 底部添加 0 填充
|
||||
yabai -m config external_bar all:0:0
|
||||
|
||||
# ================================ 规则 ================================
|
||||
# 打开系统偏好设置,不使用平铺模式
|
||||
yabai -m rule --add app="^系统偏好设置$" manage=off
|
||||
yabai -m rule --add app="^提醒事项$" manage=off
|
||||
yabai -m rule --add app="^关于本机$" manage=off
|
||||
# float system preferences
|
||||
yabai -m rule --add app="^System Preferences$" manage=off
|
||||
# show digital colour meter topmost and on all spaces
|
||||
yabai -m rule --add app="^Digital Colou?r Meter$" sticky=on
|
||||
|
||||
echo "yabai configuration loaded.."
|
||||
Reference in New Issue
Block a user