GSConnect / gnome-shell-extension-gsconnect

KDE Connect implementation for GNOME
GNU General Public License v2.0
3.21k stars 258 forks source link

Send clipboard on demand only and/or send text #1167

Open getzze opened 3 years ago

getzze commented 3 years ago

The clipboard plugin is nice but it shares EVERY text with the phone. It would be nice to have the possibility to send the clipboard on demand, like this new feature request in KDE connect: https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/396

Otherwise (or in addition to the other feature), a button that opens a small text entry (like the sms window) and then sends this text to the phone would be great. On Android you can do something similar by selecting text and sharing it via KDE connect.

andyholmes commented 3 years ago

This should be easy already, there are settings in the preferences for automatic bi-directional sync:

Screenshot from 2021-09-08 15-37-19

And there are two GActions, exposed over D-Bus, device.clipboardPull and device.clipboardPush that can be assigned to keyboard shortcuts. Were you thinking something else?

getzze commented 3 years ago

The GAction would have to be defined for a specific device, but I have several devices. I was thinking of buttons in the menu: gsconnect

andyholmes commented 3 years ago

If you add clipboardPush/clipboardPull to the GSettings key:

/org/gnome/shell/extensions/gsconnect/<device-id>/menu-actions

Whose default value is

["sms", "ring", "mount", "commands", "share", "photo", "keyboard"]

Do they show up in the menu then? You might have to restart the service for it to take effect (I can't remember).

getzze commented 3 years ago

I don't have the menu-actions key in /org/gnome/shell/extensions/gsconnect/<device-id>/ and I don't know how to create it with dconf Editor.

andyholmes commented 3 years ago

Something like this should work:

dconf write /org/gnome/shell/extensions/gsconnect/<device-id>/menu-actions '["sms", "ring", "mount", "commands", "share", "photo", "keyboard", "clipboardPull", "clipboardPush"]'
getzze commented 3 years ago

It's not working, the actions in the menu are unchanged (Messaging, Ring, ...)

In the meantime I remembered that you can send text with the Share action, it is so hidden that I had forgotten :)

andyholmes commented 3 years ago

Did you restart the service? I'm not sure there's any machinery for handling the menu actions changing on the fly.

touch ~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/daemon.js
getzze commented 3 years ago

I logged out after sending the dconf command. When I logged in, the previous items appeared in the menu of my device, then evething disappeared after 1s. Then some time later the items reappeared. But clipboardPull and clipboardPush never appeared. I have another device connected that showed the normal items all the time. It seems it first showed the items in cache, then tried to add the new ones but failed so all the menu disappeared and then it went back to default afterwards.

andyholmes commented 3 years ago

Yes, there's no real testing that case. The menu code could all probably use a good look.

lantw44 commented 3 months ago

This command works for me:

dconf write /org/gnome/shell/extensions/gsconnect/device/<device-id>/menu-actions '["sms", "ring", "mount", "commands", "share", "keyboard", "clipboardPush"]'

I use the panel instead of the default user menu due to https://github.com/GSConnect/gnome-shell-extension-gsconnect/issues/1640:

螢幕快照 2024-07-28 18-11-39

Now clipboard push is available as the second item.

ferdnyc commented 3 months ago

Huh. How strange, that it would end up out of order like that. Looking at the code, items are even inserted with an index number that corresponds to their position in the menu-actions list — unless they don't have an index (meaning it gets defaulted to -1, in which case they're appended to the list. But I can't see why something would be inserted forward of its real position.

Hmm. Unless maybe the insertion somehow wraps around — because, the index of clipboardPush would be 6, and at the time it's inserted the menu would only have 5 items (since "commands" appears to be missing).

...But, no, if that were the case then "share" and "keyboard" would have the same issue. (Oh, but wait, they're also out of order — or, rather, their order is swapped. How odd.)