Skip to content

fix cliboard using a deprecated API#1549

Open
themoonisacheese wants to merge 5 commits into
tsl0922:mainfrom
themoonisacheese:main
Open

fix cliboard using a deprecated API#1549
themoonisacheese wants to merge 5 commits into
tsl0922:mainfrom
themoonisacheese:main

Conversation

@themoonisacheese

Copy link
Copy Markdown

ttyd's onSelectionChange handler uses document.execCommand("copy") to copy selected text. This is broken in two
ways:

  1. document.execCommand is deprecated and being removed from browsers.
  2. It never worked on canvas-rendered terminals. xterm.js renders to a <canvas> element, which has no DOM text selection. execCommand("copy") copies the browser's text selection, which is empty on a canvas, so nothing ever reaches the clipboard regardless of whether the API is available.

The fix replaces document.execCommand("copy") with navigator.clipboard.writeText(terminal.getSelection()) :

  • navigator.clipboard.writeText() is the modern Clipboard API and is the only path that will work going forward.
  • terminal.getSelection() reads text from xterm.js's internal buffer model, which works correctly on both canvas and DOM renderers.

Spawn dbus-monitor as a libuv subprocess to watch for desktop
notifications on the session bus. Notifications are parsed, filtered
to avoid browser feedback loops, and forwarded to all connected
clients as native Browser Notifications.

New option: -N, --monitor-notifications
When no notification daemon owns org.freedesktop.Notifications,
ttyd registers itself via sd-bus (dedicated thread + uv_async_t).
Falls back to dbus-monitor when a daemon already exists.
Send DECSET 1004 on connect so Crush's DECRPM ?1004 query reports
supported, and send focus/blur events so Crush's shouldSendNotification
gate check passes (condition tsl0922#3: window not focused).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant