From 0c1da98fbed30239f06731b7bef2de6b423279c7 Mon Sep 17 00:00:00 2001 From: Elias Almqvist Date: Thu, 25 Jul 2024 17:26:02 -0700 Subject: [PATCH] add yabai + skhd configs --- nix-darwin/modules/skhd.nix | 71 ++++++++++++++++++++++++++++++++++++ nix-darwin/modules/yabai.nix | 23 ++++++++++++ 2 files changed, 94 insertions(+) diff --git a/nix-darwin/modules/skhd.nix b/nix-darwin/modules/skhd.nix index e69de29..4a1c7ab 100644 --- a/nix-darwin/modules/skhd.nix +++ b/nix-darwin/modules/skhd.nix @@ -0,0 +1,71 @@ +{ config, pkgs, ... }: + +{ + home.file.".skhdrc" = { + executable = true; + text = '' + # Mod1 is alt, Mod4 is cmd + + # Terminal + cmd - return : open -n /Applications/iTerm.app + + # dmenu equivalent (you may want to install choose-gui or another launcher) + cmd - p : open -n /Applications/choose-gui.app + + # Close window + cmd + shift - c : yabai -m window --close + + # Focus window + cmd - j : yabai -m window --focus south + cmd - k : yabai -m window --focus north + cmd - h : yabai -m window --focus west + cmd - l : yabai -m window --focus east + + # Move window + shift + cmd - j : yabai -m window --swap south + shift + cmd - k : yabai -m window --swap north + shift + cmd - h : yabai -m window --swap west + shift + cmd - l : yabai -m window --swap east + + # Resize window + shift + alt - h : yabai -m window --resize left:-50:0 ; yabai -m window --resize right:-50:0 + shift + alt - j : yabai -m window --resize bottom:0:50 ; yabai -m window --resize top:0:50 + shift + alt - k : yabai -m window --resize top:0:-50 ; yabai -m window --resize bottom:0:-50 + shift + alt - l : yabai -m window --resize right:50:0 ; yabai -m window --resize left:50:0 + + # Toggle floating + shift + alt - space : yabai -m window --toggle float + + # Make window fullscreen + alt - f : yabai -m window --toggle zoom-fullscreen + + # Toggle between layouts + alt - space : yabai -m space --layout $(yabai -m query --spaces --space | jq -r 'if .type == "bsp" then "float" else "bsp" end') + + # Focus workspace + 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 workspace + 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 + + # Restart yabai + shift + cmd - q : yabai --restart-service + ''; + }; +} diff --git a/nix-darwin/modules/yabai.nix b/nix-darwin/modules/yabai.nix index e69de29..ed417c5 100644 --- a/nix-darwin/modules/yabai.nix +++ b/nix-darwin/modules/yabai.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: + +{ + # Create configuration files for yabai and skhd + home.file.".yabairc" = { + executable = true; + text = '' + #!/usr/bin/env sh + + # load scripting addition + sudo yabai --load-sa + yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa" + + # global settings + yabai -m config layout bsp + yabai -m config window_placement second_child + yabai -m config split_ratio 0.50 + yabai -m config auto_balance on + + # Add more yabai configuration here + ''; + }; +}