kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.25k stars 976 forks source link

The "listen_on" option in config file doesn't seem to work #5584

Closed YorkZ closed 2 years ago

YorkZ commented 2 years ago

Describe the bug The listen_on option in config file doesn't seem to have an effect while specifying --listen-on on the command line works.

To Reproduce Steps to reproduce the behavior:

  1. Add the following line to ~/.config/kitty
allow_remote_control yes
listen_on unix:@mykitty
  1. Start kitty with
kitty --single-instance
  1. In the kitty terminal window, type:
kitty @ --to unix:@mykitty ls
  1. See error
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/bin/../lib/kitty/__main__.py", line 7, in <module>
    main()
  File "/usr/bin/../lib/kitty/kitty/entry_points.py", line 206, in main
    func(sys.argv[1:])
  File "/usr/bin/../lib/kitty/kitty/entry_points.py", line 23, in remote_control
    rc_main(args)
  File "/usr/bin/../lib/kitty/kitty/remote_control.py", line 504, in main
    response = do_io(global_opts.to, send, no_response, response_timeout, encrypter)
  File "/usr/bin/../lib/kitty/kitty/remote_control.py", line 314, in do_io
    with io:
  File "/usr/bin/../lib/kitty/kitty/remote_control.py", line 256, in __enter__
    self.socket.connect(self.address)
ConnectionRefusedError: [Errno 111] Connection refused

Environment details

Press Ctrl+Shift+F6 (cmd+option+comma on macOS) in kitty, to copy debug output about kitty and its
configuration to the clipboard and paste it here. 

kitty 0.26.3 created by Kovid Goyal
Linux york-asus 5.19.13-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 04 Oct 2022 14:36:58 +0000 x86_64
IP: 4{eno2}
Arch Linux 5.19.13-arch1-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/bash
Loaded config files:
  ~/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control yes
font_size            10.0
listen_on            unix:@mykitty
scrollback_lines     262144
shell                /bin/fish
startup_session      ~/.config/kitty/home
Added shortcuts:
    alt+h →  launch --type=os-window --stdin-source=@screen_scrollback vim -R + -
    alt+j →  scroll_line_down
    alt+k →  scroll_line_up
    alt+n →  next_window
    alt+p →  previous_window
    alt+t →  next_layout
    ctrl+, →  move_tab_backward
    ctrl+- →  change_font_size current -2.0
    ctrl+. →  move_tab_forward
    ctrl+= →  change_font_size current +2.0
    ctrl+alt+n →  last_used_layout
    ctrl+alt+s →  goto_layout stack
    ctrl+alt+t →  goto_layout tall
    ctrl+alt+w →  set_tab_title
    ctrl+backspace →  change_font_size current 0
    ctrl+down →  scroll_line_down
    ctrl+end →  scroll_end
    ctrl+home →  scroll_home
    ctrl+left →  previous_tab
    ctrl+page_down →  scroll_page_down
    ctrl+page_up →  scroll_page_up
    ctrl+q →  close_tab
    ctrl+right →  next_tab
    ctrl+up →  scroll_line_up
    ctrl+v →  paste_from_clipboard

Important environment variables seen by the kitty process:
    PATH                                /usr/lib/ccache/bin:~/.local/bin:~/bin:~/.local/share/gem/ruby/2.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/sbin:/sbin:/bin:~/.cask/bin
    LANG                                en_US.UTF-8
    EDITOR                              emacsclient -c
    SHELL                               /bin/bash
    DISPLAY                             :0.0
    USER                                xxxxx
    XDG_SEAT                            seat0
    XDG_SESSION_TYPE                    tty
    XDG_SESSION_CLASS                   user
    XDG_VTNR                            1
    XDG_SESSION_ID                      1
    XDG_RUNTIME_DIR                     /run/user/1000

On older versions of kitty, run kitty --debug-config instead

Additional context Try to reproduce the problem with kitty --config NONE if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.

kovidgoyal commented 2 years ago

Read the docs of the listen_on config option, in particular what it says about the PID being appended. https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.listen_on

YorkZ commented 2 years ago

Thank you for the ultra fast responding. But I don't really understand what the doc means regarding the {kitty_pid} thing. I think the doc is not clear enough on this, and therefore would you mind explaining it a bit more?

page-down commented 2 years ago

You can run multiple kitty processes, all loading the same configuration file. However, different processes cannot listen to the same socket, so different sockets are needed. If you don't explicitly specify {kitty_pid}, then the process pid will be automatically appended to the end to listen to different sockets.

I believe the documentation is clear on this.

YorkZ commented 2 years ago

Sorry but I'm still very confused. So since

allow_remote_control yes
listen_on unix:@mykitty

in the config file doesn't work, what should be changed in order for it to work? I don't understand how to apply {kitty_pid} thing, so I just guessed:

listen_on unix:@mykitty{kitty_pid}

but that still didn't make any difference. Please forgive me if I did stupid thing about this.

page-down commented 2 years ago

... what should be changed in order for it to work?

Fix your kitty @ --to argument. The socket you try to connect to via kitty @ does not match what kitty actually listens to.

kitty -o allow_remote_control=y -o listen_on=unix:@mykitty

printenv KITTY_LISTEN_ON
# unix:@mykitty-12345

kitty @ --to "unix:@mykitty-$KITTY_PID" ls