Skip to content

Fix "Copy Dropbox link" not populating the clipboard on Wayland - #176

Open
shonie wants to merge 1 commit into
dropbox:masterfrom
shonie:wayland-clipboard-gdk-backend
Open

shonie wants to merge 1 commit into
dropbox:masterfrom
shonie:wayland-clipboard-gdk-backend

Conversation

@shonie

@shonie shonie commented Oct 31, 2026

Copy link
Copy Markdown

Summary

Fixes #164: "Copy Dropbox link" shows the "link copied" notification but leaves the clipboard empty on Wayland sessions (GNOME and KDE).

The Nautilus extension only sends icon_overlay_context_action / copy_link to dropboxd; the daemon writes the clipboard itself. dropboxd is a GTK3 app, so on a Wayland session it uses GDK's Wayland backend. Wayland compositors ignore clipboard writes from clients that don't have keyboard focus, and dropboxd only has a tray icon, so the write is silently dropped.

This change makes dropbox start launch dropboxd with GDK_BACKEND=x11,wayland when XDG_SESSION_TYPE=wayland and GDK_BACKEND isn't already set. Under XWayland the clipboard write succeeds and the compositor forwards it to the Wayland clipboard; if XWayland isn't available, GTK falls back to Wayland. The environment setup is moved into a small dropboxd_env() helper, next to the existing Unity/Budgie workaround.

Test plan

  • python3 ./dropbox_test.py passes.
  • ruff format --diff and ruff check (ruff 0.16.9, as pinned in tools/requirements.txt) pass.
  • Manual, Arch Linux / GNOME on Wayland, dropbox 278.3.3901:
    • With the daemon on the default backend, sending copy_link over ~/.dropbox/command_socket returns ok, but wl-paste and xclip -o -sel clipboard both stay unchanged.
    • After restarting the daemon with GDK_BACKEND=x11,wayland, the same command puts the shared link in both the Wayland and X11 clipboards.
    • A minimal background GTK3 process calling Gtk.Clipboard.set_text() shows the same behaviour: dropped with GDK_BACKEND=wayland, works with GDK_BACKEND=x11.

dropboxd is a GTK3 app and picks GDK's Wayland backend on Wayland
sessions. Wayland compositors ignore clipboard writes from clients
without keyboard focus, and dropboxd only has a tray icon, so the
"Copy Dropbox link" action silently fails while still showing the
"link copied" notification.

When starting dropboxd in a Wayland session, prefer GTK's X11 backend
(falling back to Wayland) unless GDK_BACKEND is already set. XWayland
forwards the X11 clipboard to the Wayland clipboard.

Fixes dropbox#164.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLAassistant

CLAassistant commented Oct 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@shonie

shonie commented Oct 31, 2026

Copy link
Copy Markdown
Author

While this is a workaround for specific types of setups, there is also a cleaner fix that I'd like to check with you before implementing.

The extension runs inside Nautilus, which is the focused app when you click "Copy Dropbox link", so it's allowed to write the clipboard on Wayland. The daemon already has get_shared_link, which returns the link without copying it (the CLI's dropbox sharelink uses it). So for the copy_link verb, menu_item_cb could call get_shared_link and set the clipboard itself with gdk_clipboard_set_text(). The extension already links GTK4. Every other verb would still go to the daemon as today.

Compared with this PR, that would:

  • work on every desktop and session type, with or without XWayland
  • work however the daemon is started (including distro packages that don't use dropbox start)
  • leave the daemon's GTK backend unchanged

The trade-off is the "link copied" notification, which the daemon shows today. The extension could send an equivalent one through org.freedesktop.Notifications (Dropbox name and icon, click opens the link), or skip it.

Would you prefer that approach, either replacing this PR or alongside it? Or would you rather keep the change in the launcher? Also, do you know whether copy_link a stable verb name to rely on?

@coreyberla

Copy link
Copy Markdown
Contributor

While this is a workaround for specific types of setups, there is also a cleaner fix that I'd like to check with you before implementing.

The extension runs inside Nautilus, which is the focused app when you click "Copy Dropbox link", so it's allowed to write the clipboard on Wayland. The daemon already has get_shared_link, which returns the link without copying it (the CLI's dropbox sharelink uses it). So for the copy_link verb, menu_item_cb could call get_shared_link and set the clipboard itself with gdk_clipboard_set_text(). The extension already links GTK4. Every other verb would still go to the daemon as today.

Compared with this PR, that would:

* work on every desktop and session type, with or without XWayland

* work however the daemon is started (including distro packages that don't use dropbox start)

* leave the daemon's GTK backend unchanged

The trade-off is the "link copied" notification, which the daemon shows today. The extension could send an equivalent one through org.freedesktop.Notifications (Dropbox name and icon, click opens the link), or skip it.

Would you prefer that approach, either replacing this PR or alongside it? Or would you rather keep the change in the launcher? Also, do you know whether copy_link a stable verb name to rely on?

nautilus dev here. This is the right approach (calling gdk_clipboard_set_text() in the extension). The patch in this MR is fragile.

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.

The copy link context menu item doesn't populate the clipboard

3 participants