.dotfiles/pkgs/flake/e/default.nix
2026-03-06 00:51:55 +01:00

30 lines
774 B
Nix

{ name, writeShellApplication, emacs30-pgtk, sway, jq, ... }:
writeShellApplication {
inherit name;
runtimeInputs = [ emacs30-pgtk sway jq ];
text = ''
wait=0
while :; do
case ''${1:-} in
-w | --wait)
wait=1
;;
*) break ;;
esac
shift
done
STR=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]) | select(.name == "__i3_scratch")' | grep kittyterm || true)
if [ "$STR" == "" ]; then
swaymsg '[title="kittyterm"]' scratchpad show
emacsclient -c -a "" "$@"
swaymsg '[title="kittyterm"]' scratchpad show
else
if [[ $wait -eq 0 ]]; then
emacsclient -n -c -a "" "$@"
else
emacsclient -c -a "" "$@"
fi
fi
'';
}