Skip to content

panel kitten --toggle-visibility sometimes doesn't update layer shell config #8984

Closed

Description

@alex-huff

Describe the bug
When using --toggle-visibility with a single instance panel kitten the layer shell configuration is only updated if the given configuration is different than the original configuration when the kitten was first launched.

To Reproduce
Steps to reproduce the behavior:

  1. run kitten panel --single-instance --instance-group=foo --edge=top &
  2. run kitten panel --single-instance --instance-group=foo --edge=bottom --toggle-visibility
  3. run kitten panel --single-instance --instance-group=foo --edge=top --toggle-visibility
  4. Notice the panel is still anchored to the bottom. This is because the layer shell configuration in step 3 is the same as in step 1 (the original configuration).

Environment details

kitty 0.42.2 (c30f8cec46) created by Kovid Goyal
Linux desk 6.16.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 04 Sep 2025 23:18:13 +0000 x86_64
Arch Linux 6.16.5-arch1-1 (/dev/tty)
DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland (sway version 1.11-6db1dede (Jun 10 2025, branch 'tabbed-stacked-layout-gaps')) missing: blur icon bell window-tag window-state-suspended color-manager
OpenGL: '4.6 (Core Profile) Mesa 25.2.2-arch1.1' Detected version: 4.6
Frozen: False
Fonts:
  medium: FiraCodeRoman-Regular: /home/alex/.local/share/fonts/FiraCode/variable_ttf/FiraCode-VF.ttf:131072
          Features: ()
    bold: FiraCodeRoman-SemiBold: /home/alex/.local/share/fonts/FiraCode/woff2/FiraCode-VF.woff2:262144
          Features: ()
  italic: FiraCodeRoman-Regular: /home/alex/.local/share/fonts/FiraCode/woff2/FiraCode-VF.woff2:131072
          Features: ()
      bi: FiraCodeRoman-SemiBold: /home/alex/.local/share/fonts/FiraCode/woff2/FiraCode-VF.woff2:262144
          Features: ()
Paths:
  kitty: /home/alex/dev/kitty/kitty/launcher/kitty
  base dir: /home/alex/dev/kitty
  extensions dir: /home/alex/dev/kitty/kitty
  system shell: /bin/bash
System color scheme: light. Applied color theme type: none
Loaded config files:
  /home/alex/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control       password
bell_path                  /home/alex/.assets/bell.wav
box_drawing_scale          (0.5, 1.0, 1.5, 2.0)
confirm_os_window_close    (0, False)
cursor_stop_blinking_after 0
disable_ligatures          2
font_family                Fira Code
font_size                  16.0
listen_on                  unix:$XDG_RUNTIME_DIR/kitty
modify_font:
    baseline 1
paste_actions              frozenset({'confirm-if-large'})
placement_strategy         top-left
remote_control_password: REDACTED FOR SECURITY
selection_background       None
selection_foreground       None
shell_integration          frozenset({'no-cursor'})
symbol_map:
	U+e000 - U+e00a → Symbols Nerd Font Mono
	U+e0a0 - U+e0c8 → Symbols Nerd Font Mono
	U+e0ca - U+e0ca → Symbols Nerd Font Mono
	U+e0cc - U+e0d7 → Symbols Nerd Font Mono
	U+e200 - U+e2a9 → Symbols Nerd Font Mono
	U+e300 - U+e3e3 → Symbols Nerd Font Mono
	U+e5fa - U+e6b1 → Symbols Nerd Font Mono
	U+e700 - U+e7c5 → Symbols Nerd Font Mono
	U+ea60 - U+ebeb → Symbols Nerd Font Mono
	U+ed00 - U+efc1 → Symbols Nerd Font Mono
	U+f000 - U+f2e0 → Symbols Nerd Font Mono
	U+f000 - U+f2ff → Symbols Nerd Font Mono
	U+f300 - U+f372 → Symbols Nerd Font Mono
	U+f400 - U+f533 → Symbols Nerd Font Mono
	U+f0001 - U+f1af0 → Symbols Nerd Font Mono
watcher:
{'watcher.py': 'watcher.py'}
wayland_enable_ime         False
window_padding_width       FloatEdges(left=6.0, top=6.0, right=6.0, bottom=6.0)
Added shortcuts:
	kitty_mod+d →  new_os_window_with_cwd
Changed shortcuts:
	kitty_mod++ →  no-op
	kitty_mod+- →  change_font_size current -2.0
	kitty_mod+= →  change_font_size current +2.0
	kitty_mod+a > m →  show_scrollback, set_background_opacity default, set_background_opacity 1, set_background_opacity -0.1, set_background_opacity +0.1
	kitty_mod+backspace →  change_font_size current 0
	kitty_mod+h →  no-op
	kitty_mod+kp_add →  no-op
	kitty_mod+kp_subtract →  no-op
	kitty_mod+l →  no-op
	kitty_mod+w →  no-op
Colors:
	background                 #f9f5d7   
	color0                     #ebdbb2   
	color1                     #cc241d   
	color10                    #79740e   
	color11                    #b57614   
	color12                    #076678   
	color13                    #8f3f71   
	color14                    #427b58   
	color15                    #282828   
	color2                     #98971a   
	color3                     #d79921   
	color4                     #458588   
	color5                     #b16286   
	color6                     #689d6a   
	color7                     #7c6f64   
	color8                     #928374   
	color9                     #9d0006   
	cursor                     #665c54   
	cursor_text_color          #bdae93   
	foreground                 #3c3836   
	url_color                  #458588   

Important environment variables seen by the kitty process:
	PATH                                /home/alex/dev/kitty/kitty/launcher:/home/alex/.pyenv/shims:/home/alex/.pyenv/bin:/home/alex/.pyenv/bin:/home/alex/.local/share/JetBrains/Toolbox/scripts:/home/alex/.local/bin:/home/alex/.cargo/bin:/home/alex/go/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin:/var/lib/snapd/snap/bin
	LANG                                en_US.UTF-8
	EDITOR                              vim
	SHELL                               /bin/bash
	DISPLAY                             :0
	WAYLAND_DISPLAY                     wayland-1
	USER                                alex
	XCURSOR_SIZE                        40
	XDG_SEAT                            seat0
	XDG_SESSION_TYPE                    wayland
	XDG_CURRENT_DESKTOP                 sway
	XDG_SESSION_CLASS                   user
	XDG_VTNR                            1
	XDG_SESSION_ID                      1
	XDG_RUNTIME_DIR                     /run/user/1000
	XDG_DATA_DIRS                       /home/alex/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop

Additional context
Basically it is impossible to reset a panel kitten to its original configuration using --toggle-visibility since set_layer_shell_config is only called if the given layer shell configuration is not equal to run_app.layer_shell_config, which is the initial configuration.

Activity

  1. kovidgoyal commented on Sep 19, 2025

    @kovidgoyal
    Owner

    Note I havent tested the fix as I am rather busy at the moment, so I
    leave that to you.

  2. added a commit that references this issue on Sep 19, 2025
    9393eeb
  3. alex-huff commented on Sep 19, 2025

    @alex-huff
    ContributorAuthor

    This partially fixes the issue but any updates to the layer shell config over remote control aren't saved to run_app.layer_shell_config and so they are not seen by handle_single_instance_command.

    For example:

    1. kitty +kitten panel --config=NONE --single-instance --instance-group=foo --listen-on=unix:@panel-socket --override=allow_remote_control=socket-only --edge=top
    2. kitten @ --to=unix:@panel-socket --use-password=never resize-os-window --action=toggle-visibility
    3. kitten @ --to=unix:@panel-socket --use-password=never resize-os-window --action=os-panel edge=bottom
    4. kitty +kitten panel --single-instance --instance-group=foo --edge=top --toggle-visibility
    5. Notice the panel is still anchored to the bottom.

    While looking at the resize-os-window remote command code I noticed that you can get the current layer shell configuration for a window with layer_shell_config_for_os_window. Using this instead of run_app.layer_shell_config seems to fix this issue:

    diff --git a/kittens/panel/main.py b/kittens/panel/main.py
    index 6f2ac90b5..c4cf26d7f 100644
    --- a/kittens/panel/main.py
    +++ b/kittens/panel/main.py
    @@ -25,6 +25,7 @@
         GLFW_LAYER_SHELL_OVERLAY,
         GLFW_LAYER_SHELL_PANEL,
         GLFW_LAYER_SHELL_TOP,
    +    layer_shell_config_for_os_window,
         set_layer_shell_config,
         toggle_os_window_visibility,
     )
    @@ -110,7 +111,6 @@ def have_config_files_been_updated(config_files: Iterable[str]) -> bool:
     def handle_single_instance_command(boss: BossType, sys_args: Sequence[str], environ: Mapping[str, str], notify_on_os_window_death: str | None = '') -> None:
         global args
         from kitty.cli import parse_override
    -    from kitty.main import run_app
         from kitty.tabs import SpecialWindow
         try:
             new_args, items = parse_panel_args(list(sys_args[1:]))
    @@ -118,17 +118,17 @@ def handle_single_instance_command(boss: BossType, sys_args: Sequence[str], envi
             log_error(f'Invalid arguments received over single instance socket: {sys_args} with error: {e}')
             return
         lsc = layer_shell_config(new_args)
    -    layer_shell_config_changed = lsc != run_app.layer_shell_config
         config_changed = have_config_files_been_updated(new_args.config) or args.config != new_args.config or args.override != new_args.override
         args = new_args
         if config_changed:
             boss.load_config_file(*args.config, overrides=tuple(map(parse_override, new_args.override)))
         if args.toggle_visibility and boss.os_window_map:
             for os_window_id in boss.os_window_map:
    +            existing = layer_shell_config_for_os_window(os_window_id)
    +            layer_shell_config_changed = not existing or any(f for f in lsc._fields if getattr(lsc, f) != existing[f])
                 toggle_os_window_visibility(os_window_id)
                 if layer_shell_config_changed:
                     set_layer_shell_config(os_window_id, lsc)
    -                run_app.layer_shell_config = lsc
             return
         items = items or [kitten_exe(), 'run-shell']
         os_window_id = boss.add_os_panel(lsc, args.cls, args.name)

    However, from looking at the code for layer_shell_config_for_os_window it seems to returns None if kitty isn't running under Wayland.

    static PyObject*
    layer_shell_config_for_os_window(PyObject *self UNUSED, PyObject *wid) {
        if (!PyLong_Check(wid)) { PyErr_SetString(PyExc_TypeError, "os_window_id must be a int"); return NULL; }
    #ifdef __APPLE__
        (void)layer_shell_config_to_python;
        Py_RETURN_NONE;
    #else
        if (!global_state.is_wayland) Py_RETURN_NONE;
        id_type id = PyLong_AsUnsignedLongLong(wid);
        OSWindow *w = os_window_for_id(id);
        if (!w || !w->handle) Py_RETURN_NONE;
        const GLFWLayerShellConfig *c = glfwGetLayerShellConfig(w->handle);
        if (!c) Py_RETURN_NONE;
        return layer_shell_config_to_python(c);
    #endif
    }

    Is this intentional or was layer_shell_config_for_os_window just never updated when macOS and X11 became supported?

  4. added 2 commits that reference this issue on Jul 8, 2026
    91ebc14
    66f2343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions