See https://sw.kovidgoyal.net/kitty/remote-control.html
