Skip to content

Commit

Permalink
Merge pull request #76 from sbulav/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
sbulav authored Jan 15, 2024
2 parents 445a8cc + 8664d6f commit f9b49f1
Show file tree
Hide file tree
Showing 37 changed files with 317 additions and 56 deletions.
4 changes: 4 additions & 0 deletions fish/functions/cdd.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Defined in - @ line 1
function cdd --wraps='~/dotfiles/nix' --wraps='cd ~/dotfiles/nix' --description 'alias cdd=cd ~/dotfiles/nix'
cd ~/dotfiles/nix $argv;
end
3 changes: 1 addition & 2 deletions lf/lfrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ map gd cd ~/Documents
map gD cd ~/Downloads
map gp cd ~/Pictures
map gc cd ~/.config
map gp cd ~/git_pagaya/
map gt cd ~/git_pagaya/sb-tools/
map gn cd ~/dotfiles/nix/

# Tips

Expand Down
4 changes: 3 additions & 1 deletion nix/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
user = "%USER%";
in {
imports = [
./home-manager.nix
../shared
../shared/cachix
./home-manager.nix
./skhd.nix
./yabai.nix
];

# Auto upgrade nix package and the daemon service.
Expand Down
2 changes: 1 addition & 1 deletion nix/darwin/home-manager.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ in {
home.enableNixpkgsReleaseCheck = false;
home.packages = pkgs.callPackage ./packages.nix {};

home.stateVersion = "23.05";
home.stateVersion = "23.11";
programs = import ../shared/home-manager.nix {inherit config pkgs lib;};
};
};
Expand Down
138 changes: 138 additions & 0 deletions nix/darwin/skhd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
launchd.user.agents.skhd.serviceConfig = {
StandardOutPath = "/tmp/skhd.log";
StandardErrorPath = "/tmp/skhd.log";
};
services.skhd = {
enable = true;
skhdConfig = ''
# Default mode
:: default
# Workspace focus
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 - 0 : yabai -m space --focus 10
alt - up : yabai -m space --focus 2
alt - down : yabai -m space --focus (yabai -m query --spaces --display | jq 'map(select(."is-native-fullscreen" == true))[-1].index')
# change focus between external displays (left and right)
ctrl + alt - left : yabai -m display --focus west
ctrl + alt - right : yabai -m display --focus east
# Move windows to another workspace
ctrl + shift - 1 : yabai -m window --space 1
ctrl + shift - 2 : yabai -m window --space 2
ctrl + shift - 3 : yabai -m window --space 3
ctrl + shift - 4 : yabai -m window --space 4
ctrl + shift - 5 : yabai -m window --space 5
ctrl + shift - 6 : yabai -m window --space 6
ctrl + shift - 7 : yabai -m window --space 7
ctrl + shift - 8 : yabai -m window --space 8
ctrl + shift - 9 : yabai -m window --space 9
ctrl + shift - 0 : yabai -m window --space 10
# Navigation
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 - left : yabai -m window --focus west
alt - down : yabai -m window --focus south
alt - up : yabai -m window --focus north
alt - right : yabai -m window --focus east
# Close current window
alt - q : yabai -m window --close
# Moving windows
shift + alt - h : yabai -m window --warp west
shift + alt - j : yabai -m window --warp south
shift + alt - k : yabai -m window --warp north
shift + alt - l : yabai -m window --warp east
# Move floating window
shift + alt - h : yabai -m window --move rel:-20:0
shift + alt - j : yabai -m window --move rel:0:20
shift + alt - k : yabai -m window --move rel:0:-20
shift + alt - l : yabai -m window --move rel:20:0
# Float/unfloat windows
shift + alt - space : yabai -m window --toggle float; \
yabai -m window --grid 4:4:1:1:2:2
# Fullscreen
alt - f : yabai -m window --toggle zoom-fullscreen
ctrl + shift - f : yabai -m window --toggle native-fullscreen
# Resize mode
:: resize @
## Enter resize mode
alt - r ; resize
## Leave resize mode
resize < escape ; default
## Resize mode key bindings
resize < h : \
yabai -m window --resize left:-20:0 ; \
yabai -m window --resize right:-20:0
resize < j : \
yabai -m window --resize bottom:0:20 ; \
yabai -m window --resize top:0:20
resize < k : \
yabai -m window --resize top:0:-20 ; \
yabai -m window --resize bottom:0:-20
resize < l : \
yabai -m window --resize right:20:0 ; \
yabai -m window --resize left:20:0
# Resize windows
ctrl + alt - h : \
yabai -m window --resize left:-20:0 ; \
yabai -m window --resize right:-20:0
ctrl + alt - j : \
yabai -m window --resize bottom:0:20 ; \
yabai -m window --resize top:0:20
ctrl + alt - k : \
yabai -m window --resize top:0:-20 ; \
yabai -m window --resize bottom:0:-20
ctrl + alt - l : \
yabai -m window --resize right:20:0 ; \
yabai -m window --resize left:20:0
# Toggle window split type with semicolon
ctrl + alt - e : yabai -m window --toggle split
# Balance size of windows
ctrl + alt - 0 : yabai -m space --balance
# Workspace init
ctrl + shift - n : yabai -m space --create
ctrl + shift - d : yabai -m space --destroy
# Applications
alt - x : /Users/sab/.nix-profile/bin/kitty
ctrl + alt - b: /Applications/Firefox.App/Contents/MacOS/firefox
# -- Starting/Stopping/Restarting Yabai --
# stop/start/restart yabai + skhd
ctrl + alt - q : launchctl stop org.nixos.yabai; launchctl stop org.nixos.skhd
ctrl + alt - s : launchctl start org.nixos.yabai; launchctl start org.nixos.skhd
ctrl + alt - r : launchctl stop org.nixos.yabai; launchctl stop org.nixos.skhd; launchctl start org.nixos.yabai; launchctl start org.nixos.skhd
'';
};
}
81 changes: 81 additions & 0 deletions nix/darwin/yabai.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{pkgs, ...}: {
launchd.user.agents.yabai.serviceConfig = {
StandardOutPath = "/tmp/yabai.log";
StandardErrorPath = "/tmp/yabai.log";
};
services.yabai = {
enable = true;
enableScriptingAddition = true;
config = {
# Binary space partitioning layout
layout = "bsp";
# When focusing a window, put the mouse at its center
mouse_follows_focus = "on";
# Automatically focus the window under the mouse
focus_follows_mouse = "autoraise";
# New window spawns to the right if vertical split, or bottom if
# horizontal split
window_placement = "second_child";
# Disable opacity for windows
window_opacity = "off";
# Padding added around the sides of a space
top_padding = 6;
bottom_padding = 6;
left_padding = 6;
right_padding = 6;
# Size of the gap that separates windows
window_gap = 6;
# Draw shadow for windows, window_border has been removed
window_shadow = "on";
# Add padding for external status bar
external_bar = "all:0:26";
};
extraConfig = ''
for _ in $(yabai -m query --spaces | jq '.[].index | select(. > 6)'); do
yabai -m space --destroy 7
done
function setup_space {
local idx="$1"
local name="$2"
local space=
echo "setup space $idx : $name"
space=$(yabai -m query --spaces --space "$idx")
if [ -z "$space" ]; then
yabai -m space --create
fi
yabai -m space "$idx" --label "$name"
}
setup_space 1 main
setup_space 2 web
setup_space 3 code
setup_space 4 social
setup_space 5 media
setup_space 6 other
yabai -m rule --add app="^Safari$" space=2
yabai -m rule --add app="^Firefox$" space=2
yabai -m rule --add app="^Kitty$" space=3
yabai -m rule --add app="^kitty$" space=3
yabai -m rule --add app="^Telegram$" space=1
yabai -m rule --add app="^Slack$" space=1
yabai -m rule --add app="^Teams$" space=1
yabai -m rule --add app="^Mail$" space=4
yabai -m rule --add app="^Calendar$" space=4
yabai -m rule --add app="^Music$" space=5
# Float system settings
yabai -m rule --add app="^(Terminal|Calculator|Software Update|Dictionary|VLC|System Preferences|System Settings|zoom.us|Photo Booth|Archive Utility)$" manage=off
yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
yabai -m rule --add app="^System Information$" label="^About This Mac$" manage=off
yabai -m rule --add app="^Cisco AnyConnect Secure Mobility Client$" manage=off
yabai -m rule --add app="^Cisco$" manage=off
# Load scripting addition
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa
'';
};
}
30 changes: 15 additions & 15 deletions nix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
pkgs = nixpkgs.legacyPackages.x86_64-linux; # Home-manager requires 'pkgs' instance
extraSpecialArgs = {inherit inputs;}; # Pass flake inputs to our config
# > Our main home-manager configuration file <
modules = [./home-manager/home.nix];
modules = [./nixos/home-manager/home.nix];
};
};
};
Expand Down
Loading

0 comments on commit f9b49f1

Please sign in to comment.