paste_from_clipboard silently consumes Ctrl+V when clipboard has no text (Wayland)
bug
**Describe the bug**
On Wayland, when the clipboard contains only non-text content (e.g. `image/png` after a screenshot), `paste_from_clipboard` silently does nothing - the key event is consumed and never reaches the running application.
This is surprising because the application may be waiting for `^V` (0x16) to handle the clipboard itself. A concrete example: Claude Code CLI detects image content by receiving `^V` in stdin, then calls `wl-paste --type image/png` directly. With Kitty intercepting Ctrl+V, image paste is completely broken.
**To Reproduce**
Steps to reproduce the behavior:
1. put an image in clipboard (e.g. after a screenshot)
`wl-copy < screenshot.png`
2. now press Ctrl+V in Kitty running any app that handles `^V` for image paste -> nothing happens, `^V` never reaches the app
With any other terminal (Ghostty, foot, etc.) the raw `^V` reaches the application and image paste works.
**Environment details**
```
kitty 0.47.1 created by Kovid Goyal
Linux arch 7.0.11-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 02 Jun 2026 18:26:58 +0000 x86_64
Arch Linux 7.0.11-arch1-1 (/dev/tty)
DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland (Hyprland v0.55.3,) missing: blur icon key-repeat top_level_drag
OpenGL: '4.6 (Core Profile) Mesa 26.1.2-arch1.1' Detected version: 4.6
Frozen: False
Fonts:
medium: MesloLGSNF-Regular: /usr/share/fonts/TTF/MesloLGSNerdFont-Regular.ttf:0
Features: ()
bold: MesloLGSNF-Bold: /usr/share/fonts/TTF/MesloLGSNerdFont-Bold.ttf:0
Features: ()
italic: MesloLGSNF-Italic: /usr/share/fonts/TTF/MesloLGSNerdFont-Italic.ttf:0
Features: ()
bi: MesloLGSNF-BoldItalic: /usr/share/fonts/TTF/MesloLGSNerdFont-BoldItalic.ttf:0
Features: ()
Paths:
kitty: /usr/bin/kitty
base dir: /usr/lib/kitty
extensions dir: /usr/lib/kitty/kitty
system shell: /usr/bin/zsh
System color scheme: no_preference. Applied color theme type: none
Loaded config files:
/home/alwx/.config/kitty/kitty.conf
Config options different from defaults:
background_opacity 0.95
font_family MesloLGS Nerd Font
font_size 12.0
Added shortcuts:
ctrl+c → copy_and_clear_or_interrupt
ctrl+k → clear
ctrl+v → kitten smart_paste.py
shift+enter → send_text all \x1b[13;2u
Colors:
active_border_color #b4befe
active_tab_background #cba6f7
active_tab_foreground #11111b
background #1e1e2e
bell_border_color #f9e2af
color0 #45475a
color1 #f38ba8
color10 #a6e3a1
color11 #f9e2af
color12 #89b4fa
color13 #f5c2e7
color14 #94e2d5
color15 #a6adc8
color2 #a6e3a1
color3 #f9e2af
color4 #89b4fa
color5 #f5c2e7
color6 #94e2d5
color7 #bac2de
color8 #585b70
color9 #f38ba8
cursor #f5e0dc
cursor_text_color #1e1e2e
foreground #cdd6f4
inactive_border_color #6c7086
inactive_tab_background #181825
inactive_tab_foreground #cdd6f4
mark1_background #b4befe
mark1_foreground #1e1e2e
mark2_background #cba6f7
mark2_foreground #1e1e2e
mark3_background #74c7ec
mark3_foreground #1e1e2e
selection_background #f5e0dc
selection_foreground #1e1e2e
tab_bar_background #11111b
url_color #f5e0dc
Important environment variables seen by the kitty process:
PATH /home/alwx/.trdl/repositories/werf/releases/2.70.0/linux-amd64/bin:/home/alwx/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
LANG en_US.UTF-8
SHELL /usr/bin/zsh
DISPLAY :1
WAYLAND_DISPLAY wayland-1
USER alwx
XCURSOR_SIZE 24
XDG_CONFIG_DIRS /etc/xdg
XDG_SESSION_PATH /org/freedesktop/DisplayManager/Session0
XDG_MENU_PREFIX hyprland-
XDG_BACKEND wayland
XDG_DATA_HOME /home/alwx/.local/share
XDG_CONFIG_HOME /home/alwx/.config
XDG_SEAT seat0
XDG_SESSION_DESKTOP Hyprland
XDG_SESSION_TYPE wayland
XDG_CURRENT_DESKTOP Hyprland
XDG_SEAT_PATH /org/freedesktop/DisplayManager/Seat0
XDG_CACHE_HOME /home/alwx/.cache
XDG_SESSION_CLASS user
XDG_VTNR 1
XDG_SESSION_ID 1
XDG_STATE_HOME /home/alwx/.local/state
XDG_RUNTIME_DIR /run/user/1000
XDG_DATA_DIRS /usr/local/share:/usr/share
```
**Additional context**
Root cause
`paste_from_clipboard` reads text from clipboard and pastes it. When clipboard has no text types, the action exits silently - a no-op. The key event is consumed regardless.
Proposed solution
A `--fallback-keys` option on paste_from_clipboard (or a new action):
`map ctrl+v paste_from_clipboard --fallback-keys ctrl+v`
When the clipboard has text -> paste as usual. When it has no text -> send the specified key sequence to the application. This is a clean opt-in with no behavior change for existing configs.
Workaround
A custom kitten checking `boss.clipboard.get_available_mime_types_for_paste()` and either calling `w.paste_with_actions(text)` or `w.write_to_child("\x16")`. Works, but shouldn't require a kitten for such a basic use case.
```python
TEXT_TYPES = {"text/plain", "text/plain;charset=utf-8", "UTF8_STRING", "STRING", "TEXT"}
def main(args):
return None
from kittens.tui.handler import result_handler
@result_handler(no_ui=True)
def handle_result(args, answer, target_window_id, boss):
w = boss.window_id_map.get(target_window_id)
if w is None:
return
mime_types = set(boss.clipboard.get_available_mime_types_for_paste())
if mime_types & TEXT_TYPES:
text = boss.clipboard.get_text()
if text:
w.paste_with_actions(text)
elif any(m.startswith("image/") for m in mime_types):
w.write_to_child("\x16")
```
0 条评论