bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.6k stars 60 forks source link

KDE Connect clipboard sync issue and --watch #241

Closed Vaisakhkm2625 closed 2 days ago

Vaisakhkm2625 commented 4 days ago

First of all, thanks for making wl-clipboard.. such a excellent replacement for xclip..

ISSUE: KDE Connect not properly integrating with wl-clipboard

Since i switched to hyprland (over a year ago), KDE Connect hasn't worked properly, Like remote desktop/clipboard sync etc Among which clipboard sync is one of the most important feature i used before that.. I haven't able to figure out if it's issue with my setup, or with KDE Connect not working with wayland (more likely) or with wl-clipboard

Workaround (or proper way? on pov of unix philosophy )

As a workaround, i decided to make shell script only to find myself more confused how wl-paste --watch works..

 wl-paste -t text --watch cat | xargs -I{} kdeconnect-cli -d a6780b4540540a1c --share-text {}

The issue is, it's only copying till the last \n char, which i understand why, but i am not sure how to get around it..

image

 wl-paste --watch kdeconnect-cli -d a6780b4540540a1c --share-text "$(wl-paste)" 

which is just sending last thing copied before running this...

image

Should i be doing some read looping to get the text continuously?

If possible, can you please help me when you have time? feel free to close the tickets if you feel like this issue don't belong here..

I am glad to help in case any help needed from my side..

bugaevc commented 3 days ago

Hi!

Note that the way you wrote it, cat is the command you pass to wl-paste --watch, and then you pipe the complete output of all cat invocations through the pipe to xargs on the other side, which will split it into lines and then call kdeconnect-cli. I don't understand what you were trying to achieve that way, and why you need the xargs here for example.

Maybe this is closer to what you wanted?

$ wl-paste -t text --watch bash -c 'kdeconnect-cli -d a6780b4540540a1c --share-text "$(</dev/stdin)"'

To make this a bit cleaner, you could make a little script out of it:

#! /bin/bash

kdeconnect-cli -d a6780b4540540a1c --share-text "$(</dev/stdin)"

save that into e.g. share-text.sh, and then run wl-paste -t text --watch share-text.sh

wl-paste --watch kdeconnect-cli -d a6780b4540540a1c --share-text "$(wl-paste)" which is just sending last thing copied before running this...

This is because your shell substitutes "$(wl-paste)" first, and only then invokes wl-paste --watch ... --share-text the-specific-thing. If you want to use shell features like pipes or command substitution inside the --watch command, you need to use an(other) instance of shell as the --watch command. Either bash -c 'actual command' or making an explicit script containing the command(s) will achieve that.

Does that make sense?

Vaisakhkm2625 commented 3 days ago

Maybe this is closer to what you wanted?

$ wl-paste -t text --watch bash -c 'kdeconnect-cli -d a6780b4540540a1c --share-text "$(</dev/stdin)"'

Wow! exactly what i wanted.. Thanks.. 😅

This is because your shell substitutes "$(wl-paste)" first, and only then invokes wl-paste --watch ... --share-text the-specific-thing. If you want to use shell features like pipes or command substitution inside the --watch command, you need to use an(other) instance of shell as the --watch command. Either bash -c 'actual command' or making an explicit script containing the command(s) will achieve that.

Does that make sense?

Yes 100% make sense.....

But actually i raised this issue is to resolve the real problem of kde connect not integrating with system clipboard... what i were trying to do it was a workaround, So, is it a issue with kde connect or something i am doing wrong, like missing some dependency ? or is it because kde connect uses some of kde specific apis under the hood to get and set clipboards? i don't remember exactly, but few of other apps also had the same issue... (like copy button on websites in firefox not working??)

for example, in kdeconnect, now even though i can sent clipboard from system to android, senting clipboard from android to linux doesn't work.. and there is no cli option like --share-text to get clipboard in the kdeconnect-cli.. :(

is there any fix needed to done? else we can close this issue...

Really thanks for responding to me..

bugaevc commented 2 days ago

But actually i raised this issue is to resolve the real problem of kde connect not integrating with system clipboard... what i were trying to do it was a workaround, So, is it a issue with kde connect or something i am doing wrong, like missing some dependency ? or is it because kde connect uses some of kde specific apis under the hood to get and set clipboards? i don't remember exactly, but few of other apps also had the same issue... (like copy button on websites in firefox not working??)

for example, in kdeconnect, now even though i can sent clipboard from system to android, senting clipboard from android to linux doesn't work.. and there is no cli option like --share-text to get clipboard in the kdeconnect-cli.. :(

is there any fix needed to done? else we can close this issue...

You should raise this with KDE Connect developers, or perhaps with Hyprland developers. There's nothing to fix on the wl-clipboard side, so let's close this indeed.

Vaisakhkm2625 commented 2 days ago

You should raise this with KDE Connect developers, or perhaps with Hyprland developers. There's nothing to fix on the wl-clipboard side, so let's close this indeed.

:) ok thanks...