How do I send a command to my headless kakoune session?


a headless session should execute a command without opening a client. For example “%s d :w”.

On system startup a headless kakoune session is startet on my system. It loads a specific file, at a specific location (i.e. a notepad in markdown syntax). Pressing <super+n> sends a command which opens a kakoune client connected to the headless session.
Now say I suddenly have to leave for an urgent cocktailparty and shutdown my system suddenly without saving my notes in the kakoune session. Then my ingenious thoughts on general laser hyper relativity would go amiss. You see the conundrum.
This problem can be solved by routinely saving the files in the headless session. Or to bind a saving command to a keycombination like <a - f4>. Now how to do that is a totally different question and here I falter.

Best Regards
– Hendrik

you on a systemd distro?

You could systemd-inhibit for the events you want to catch and run

kak -c <global-session-name> -i '.backup'

which should save a backup of your open file buffers.

That is easy. I can do that. Top.
Thank you :+1: