Compare commits

...

2 commits

Author SHA1 Message Date
f3b6610f8c little-lightning: skhd config 2024-11-25 07:48:52 -08:00
6249572392 little-lightning: remove testing pam stuff 2024-11-25 07:29:21 -08:00

View file

@ -1,8 +1,4 @@
{ pkgs, lib, self, ... }: { { pkgs, lib, self, ... }: {
imports = [
./darwin-modules/pam.nix
];
# List packages installed in system profile. To search by name, run: # List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget # $ nix-env -qaP | grep wget
environment.systemPackages = [ ]; environment.systemPackages = [ ];
@ -52,6 +48,120 @@
''; '';
}; };
services.skhd =
let
yabaiSwapToFullscreen = pkgs.writeShellApplication {
name = "yabai-swap-to-fullscreen";
runtimeInputs = [ pkgs.jq pkgs.yabai ];
text = ''
focus() {
yabai -m space --focus "$1"
}
get_fs_displays() {
yabai -m query --spaces | jq -c 'map(select(."is-native-fullscreen" == true))'
}
get_visible() {
printf '%s' "$1" | jq -c 'map(select(."is-visible" == true))'
}
is_empty() {
length="$(printf '%s' "$1" | jq 'length')"
[ "$length" -le 0 ]
}
first() {
printf '%s' "$1" | jq 'sort_by(.index) | .[0].index'
}
try_focus_visible() {
# This should be at max length 1. Though this may likely break in a multimonitor environment
visible_fullscreen_displays=$(get_visible "$1")
if ! is_empty "$visible_fullscreen_displays"; then
visible_index=$(printf '%s' "$visible_fullscreen_displays" | jq -c '.[0].index')
next_index=$((visible_index + 1))
if [ "$(printf '%s' "$fullscreen_displays" | jq "map(select(.index == $next_index)) | length")" -gt "0" ]; then
focus "$next_index"
return 0
fi
fi
return 1
}
main() {
fullscreen_displays="$(get_fs_displays)"
is_empty "$fullscreen_displays" && focus 1 && return 1
try_focus_visible "$fullscreen_displays" && return 1
focus "$(first "$fullscreen_displays")"
}
main
'';
};
# Idk if macos' 'open' is something I can find in nixpkgs lmfao
newAlacrityWindow = pkgs.writeShellApplication {
name = "new-alacritty-window";
runtimeInputs = [ pkgs.alacritty ];
text = ''
alacritty_output=$(alacritty msg create-window 2>/dev/null)
if [ -z "$alacritty_output" ]; then
open /Applications/Alacritty.app
fi
'';
};
yabai = lib.getExe pkgs.yabai;
in
{
enable = false;
skhdConfig = ''
# float / unfloat window and center on screen
alt - t : ${yabai} -m window --toggle float --grid 4:4:1:1:2:2
# open terminal window using shell script
cmd - return : ${lib.getExe newAlacrityWindow}
# rebind space switching
ctrl - left : ${yabai} -m space --focus prev || ${yabai} -m space --focus last
ctrl - right : ${yabai} -m space --focus next || ${yabai} -m space --focus first
# focusing specific spaces
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
cmd - 0x32 : ${lib.getExe yabaiSwapToFullscreen}
# moving windows
cmd + shift - 1 : ${yabai} -m window --space 1
cmd + shift - 2 : ${yabai} -m window --space 2
cmd + shift - 3 : ${yabai} -m window --space 3
# cmd + shift - 4 : ${yabai} -m window --space 4
cmd + shift - 5 : ${yabai} -m window --space 5
cmd + shift - 6 : ${yabai} -m window --space 6
cmd + shift - 7 : ${yabai} -m window --space 7
cmd + shift - 8 : ${yabai} -m window --space 8
cmd + shift - 9 : ${yabai} -m window --space 9
cmd + shift - 0x32 : ${yabai} -m window --toggle native-fullscreen
# cmd + alt - 4 : "cmd + shift - 4"
'';
};
home-manager.sharedModules = [ home-manager.sharedModules = [
{ {
home.file.".config/yabai/yabaiExe".source = lib.getExe pkgs.yabai; home.file.".config/yabai/yabaiExe".source = lib.getExe pkgs.yabai;
@ -60,7 +170,6 @@
]; ];
security.pam.enableSudoTouchIdAuth = true; security.pam.enableSudoTouchIdAuth = true;
security.pam.enableSudoTouchIdReattach = true;
users.users.zynh = { users.users.zynh = {
name = "zynh"; name = "zynh";