Skip to content

Fixed clipboard v2#96

Open
krakotay wants to merge 3 commits into
cosmic-utils:masterfrom
krakotay:fixed-clipboard-v2
Open

Fixed clipboard v2#96
krakotay wants to merge 3 commits into
cosmic-utils:masterfrom
krakotay:fixed-clipboard-v2

Conversation

@krakotay

@krakotay krakotay commented Jul 2, 2026

Copy link
Copy Markdown

Summary

This PR moves clipboard synchronization into the background service and implements reliable bidirectional text clipboard sharing.

Changes

  • Automatically sends desktop clipboard changes to connected paired devices.
  • Supports manual desktop-to-device clipboard sharing.
  • Writes clipboard content received from Android directly to the desktop clipboard.
  • Uses ext-data-control-v1, avoiding popup focus and Wayland input-serial limitations.
  • Suppresses duplicate updates and phone-to-desktop-to-phone echo loops.
  • Detects sensitive clipboard content and respects autoShare/sendPassword configuration.
  • Implements kdeconnect.clipboard.connect with local timestamps.
  • Rejects connection-time clipboard data with missing, zero, or stale timestamps.
  • Supports both D-Bus and Varlink IPC paths.
  • Reports manual-send failures when the device is unavailable or the plugin is disabled.

The initial clipboard discovered when the service starts receives timestamp 0, because its actual age is unknown. It is cached for manual sharing but does not incorrectly override a newer remote clipboard.

This PR currently handles text clipboard content only. File and image clipboard transfer is intentionally out of scope.

Testing

  • cargo check --workspace --all-targets
  • cargo test --workspace --all-targets
  • Wayland ext-data-control-v1 smoke test

My own tests

  • Android Pixel 7a, Pop!_OS 24.04 LTS with latest updates (2026-07-02). Phone2PC text clipboard works correct, no regression

Ai usage

  • codex + gpt-5.5-xhigh

@M4L-C0ntent

M4L-C0ntent commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

The fix provided does not fix the issue in a flatpak.

Sorry, I forgot to mention that testing local is fine for initial testing but should also be tested within a flatpak afterwards as this project is largely used via flatpak. This has been a struggle since the start of this project - not everything works as expected in flatpak so workarounds are sometimes needed.

Just a quick look at the code - I believe the removal of wl-clipboard-rs (this is what I was using to read the clipboard in sandboxed environment) -
the sandboxed service can not see ext-data-control-v1.

CONFIRMED IN LOGS
ERROR kdeconnect_service::dbus_interface: Background clipboard synchronization unavailable: the compositor does not advertise ext-data-control-v1

I have built-in an opt-in logger for flatpak that logs the kdeconnect-service and the applet. This has been helpful to figure out these issues.

Command to enable:

flatpak override --user --env=RUST_LOG=info --env=KDECONNECT_LOG_FILE=1 io.github.hepp3n.kdeconnect

Command to disable:

flatpak override --user --unset-env=RUST_LOG --unset-env=KDECONNECT_LOG_FILE io.github.hepp3n.kdeconnect

Logs will be generated in ~/.var/app/io.github.hepp3n.kdeconnect/data/

NOTE
You may need to restart the instance for the override to take effect. Logging out and back in can work but a faster way is to kill the cosmic panel and let all the applets in the panel restart.

killall cosmic-panel

You can always use flatpak kill commands as well as a safer alternative.
I have added the instructions to the README in needed.

Let me know if you want to continue to pursue this fix. Please close PR if not.

One last thing, if send a PR that is AI generated please put in commit message: Assisted-by: <LLM Name>

Thanks.

@M4L-C0ntent M4L-C0ntent self-assigned this Jul 3, 2026
@krakotay

krakotay commented Jul 4, 2026

Copy link
Copy Markdown
Author

Looks like I fixed it, now more testing
BTW, can I remove this useless part of code? It just makes building much slower and safes around ~5 mb storage.

[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true

@krakotay

krakotay commented Jul 4, 2026

Copy link
Copy Markdown
Author

It works
image

@M4L-C0ntent

Copy link
Copy Markdown
Collaborator

No, do not remove that. This is needed for building the flatpak correctly and keeps the flatpak size small. So not useless.

@krakotay

krakotay commented Jul 4, 2026

Copy link
Copy Markdown
Author

Ok!

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.

2 participants