yabai: init

This commit is contained in:
Nico 2025-10-19 21:01:31 +11:00
parent e3677357e0
commit beaf8a5754
Signed by: nico
SSH key fingerprint: SHA256:XuacYOrGqRxC3jVFjfLROn1CSvLz85Dec6N7O9Gwu/0
6 changed files with 164 additions and 16 deletions

View file

@ -92,7 +92,7 @@
./modules/games/darwin.nix ./modules/games/darwin.nix
./modules/applications/darwin.nix ./modules/applications/darwin.nix
./modules/desktop/de/darwin.nix ./modules/desktop/de/darwin.nix
./modules/desktop/de/aerospace.nix ./modules/desktop/de/yabai.nix
./modules/desktop/programs/sketchybar.nix ./modules/desktop/programs/sketchybar.nix
./modules/hardware/darwin.nix ./modules/hardware/darwin.nix
./modules/nix/darwin.nix ./modules/nix/darwin.nix

View file

@ -0,0 +1,20 @@
{ config, pkgs, lib, ... }:
{
services.yabai = {
enable = true;
enableScriptingAddition = true;
extraConfig = builtins.readFile ../../../stow/.config/yabai/yabairc;
};
system.defaults.spaces.spans-displays = lib.mkForce false;
environment.systemPackages = with pkgs; [
skhd
matugen
];
homebrew.brews = [
"FelixKratz/formulae/borders"
];
}

View file

@ -1,13 +0,0 @@
#!/usr/local/bin/bash
# The $SELECTED variable is available for space components and indicates if
# the space invoking this script (with name: $NAME) is currently selected:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
#sketchybar --set "$NAME" background.drawing="$SELECTED"
if [ $SELECTED = 'true' ]; then
sketchybar --set "$NAME" background.color=0xfff48fb1
else
sketchybar --set "$NAME" background.color=0xffffffff
fi

View file

@ -0,0 +1 @@
aerospace.sh

View file

@ -66,6 +66,32 @@ for sid in $(aerospace list-workspaces --all); do
done done
# background.corner_radius=0 \ # background.corner_radius=0 \
# Yabai Workspace Indictators
#
SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9")
for i in "${!SPACE_ICONS[@]}"
do
sid="$(($i+1))"
space=(
space="$sid"
icon="${SPACE_ICONS[i]}"
background.drawing=true \
icon.drawing=false \
background.height=28 \
background.border_width=0 \
background.padding_right=0 \
background.padding_left=0 \
label.color=$PRIMARY_COLOUR \
label="$sid" \
script="$PLUGIN_DIR/space.sh"
click_script="yabai -m space --focus $sid"
)
sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}"
done
# Focused window title # Focused window title
sketchybar --add item front_app left \ sketchybar --add item front_app left \
--set front_app icon="󱂬 " \ --set front_app icon="󱂬 " \

View file

@ -1,2 +1,52 @@
alt + shift - b : /opt/homebrew/bin/firefox --new-window #
alt + shift - f : open ~ # Applications
#
alt + shift - b : /Applications/Zen.app/Contents/MacOS/zen --new-window # new browser window
alt - s : screencapture -i -c # screenshot
alt + shift - f : open ~ # new finder window
#
# Yabai
#
# Workspaces
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
alt + shift - 1 : yabai -m window --space 1 --focus
alt + shift - 2 : yabai -m window --space 2 --focus
alt + shift - 3 : yabai -m window --space 3 --focus
alt + shift - 4 : yabai -m window --space 4 --focus
alt + shift - 5 : yabai -m window --space 5 --focus
alt + shift - 6 : yabai -m window --space 6 --focus
alt + shift - 7 : yabai -m window --space 7 --focus
alt + shift - 8 : yabai -m window --space 8 --focus
alt + shift - 9 : yabai -m window --space 9 --focus
# Focus next space by mission-control index if one exists, otherwise focus the first space
alt - home : yabai -m space --focus next || yabai -m space --focus first
# Focus previous space by mission-control index if one exists, otherwise focus the last space
alt - end : yabai -m space --focus prev || yabai -m space --focus last
# Layout/Focus
alt - c : yabai -m space --rotate 90
alt - f : yabai -m window --toggle zoom-fullscreen
alt - space : yabai -m window --toggle float
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
alt + shift - h : yabai -m window --swap west
alt + shift - j : yabai -m window --swap south
alt + shift - k : yabai -m window --swap north
alt + shift - l : yabai -m window --swap east

View file

@ -0,0 +1,64 @@
# Scripting Addon
# https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release)#configure-scripting-addition
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa
# Remove existing signals (in case of restart)
yabai -m signal --remove "sketchybar_space_change" 2>/dev/null
yabai -m signal --remove "sketchybar_front_app" 2>/dev/null
# Sketchybar Intergration
yabai -m signal --add event=space_changed action="sketchybar --trigger space_change" label="sketchybar_space_change"
yabai -m signal --add event=window_focused action="sketchybar --trigger front_app_switched" label="sketchybar_front_app"
# autostart
sketchybar & disown
borders & disown
sh ~/.cache/matugen-jankyborders.sh & disown
skhd & disown
# space labels
yabai -m space 1 --label browser
yabai -m space 2 --label terminal
yabai -m space 3 --label spare
yabai -m space 4 --label gaming
yabai -m space 5 --label social
yabai -m space 6 --label music
# layout
yabai -m config layout bsp
yabai -m config split_ratio 0.5
# padding
yabai -m config top_padding 6
yabai -m config bottom_padding 12
yabai -m config left_padding 12
yabai -m config right_padding 12
yabai -m config window_gap 12
# mouse support
yabai -m config mouse_modifier alt # set mouse interaction modifier key
yabai -m config mouse_action1 move # set modifier + left-click drag to move window
yabai -m config mouse_action2 resize # set modifier + right-click drag to resize window
yabai -m config focus_follows_mouse autofocus # disabled while holding mouse modifier (eg. for menubar)
yabai -m config mouse_follows_focus on
# appearance
yabai -m config window_shadow float # window shadow only on floating windows
yabai -m config window_opacity on
yabai -m config active_window_opacity 1.0
yabai -m config normal_window_opacity 0.95
# window rules
yabai -m rule --add app="^(Calculator|System Preferences|System Settings|Archive Utility)$" manage=off
yabai -m rule --add title="^Preferences" manage=off
yabai -m rule --add title="^Settings" manage=off
yabai -m rule --add app="^Steam$" manage=off
yabai -m rule --add app="^Weather$" manage=off
# Anki card preview & Anki browser
yabai -m rule --add title="^Preview" manage=off
yabai -m rule --add title="^Anki" manage=off
yabai -m rule --add title="^Browse" manage=off