1
0
Fork 0
dotfiles/system/darwin/skhd.nix

32 lines
766 B
Nix
Raw Permalink Normal View History

2023-09-07 13:13:43 +00:00
{ pkgs, ... }:
let
wezterm-pkg = pkgs.wezterm;
wezterm-app = "${wezterm-pkg}/Applications/WezTerm.app";
wezterm-cli = "${wezterm-pkg}/bin/wezterm";
yabai-bin = "${pkgs.yabai}/bin/yabai";
jq-bin = "${pkgs.jq}/bin/jq";
script-open-wezterm = pkgs.writeShellScript "skhd-open-wezterm.sh" ''
if pgrep "wezterm-gui" >/dev/null 2>&1; then
${wezterm-cli} cli spawn
wezterm_id="$(${yabai-bin} -m query --windows | ${jq-bin} '.[] | select(.app == "WezTerm") | .id')"
${yabai-bin} -m window --focus "$wezterm_id"
else
open ${wezterm-app}
fi
'';
in
{
environment.systemPackages = [ pkgs.skhd ];
services.skhd = {
enable = true;
skhdConfig = ''
2024-03-21 20:23:04 +00:00
alt + shift - return : ${script-open-wezterm}
2023-09-07 13:13:43 +00:00
'';
};
}