Saving/restoring window colors over remote control from a watcher #7874
Replies: 3 comments
-
Additionally:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
remote control doesnt send escape codes, if you want to send escape
codes you just write them to the tty device. How to do that depends on
your editor, there are some examples at
https://sw.kovidgoyal.net/kitty/mapping/#conditional-mappings-depending-on-the-state-of-the-focused-window
for vim and neovim. Which incidentally also means you dont need to try
to detect when an editor is running, instead the editor sets the user
variable and your watcher can react to that.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rivenirvana
-
For posterity's sake: vim.api.nvim_create_autocmd({ 'VimEnter', 'VimResume' }, {
group = vim.api.nvim_create_augroup('KittySetVarVimEnter', { clear = true }),
callback = function()
io.stdout:write '\x1b]30001\x1b\\'
io.stdout:write '\x1b]1337;SetUserVar=KITTY_IN_NVIM=MQ==\007'
end,
})
vim.api.nvim_create_autocmd({ 'VimLeave', 'VimSuspend' }, {
group = vim.api.nvim_create_augroup('KittyUnsetVarVimLeave', { clear = true }),
callback = function()
io.stdout:write '\x1b]30101\x1b\\'
io.stdout:write '\x1b]1337;SetUserVar=KITTY_IN_NVIM\007'
end,
})
from typing import Any, Dict
from kitty.boss import Boss
from kitty.window import Window
def on_set_user_var(boss: Boss, window: Window, data: Dict[str, Any]) -> None:
key, val = data["key"], data["value"]
if key == "KITTY_IN_NVIM" and val is not None:
boss.call_remote_control(window, ("disable_ligatures", "cursor"))
boss.call_remote_control(
window, ("set-colors", "~/.config/kitty/editor-theme.conf")
)
else:
boss.call_remote_control(window, ("disable_ligatures", "always")) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using this general watcher for some editor-specific kitty configs:
And while this works, I was wondering if I can just easily use the escape codes over remote control as described here to restore the colors on editor exit.
I've tried a couple of things, but I figured
@ launch --type=background
wouldn't work, and@ run
didn't work either. I thought@ send-text
would be the way to go, but no luck as well. Am I using@ send-text
incorrectly?I checked boss.py too and there doesn't seem to be anything else I can use.
Beta Was this translation helpful? Give feedback.
All reactions