kando-menu / kando

🥧 The Cross-Platform Pie Menu.
https://kando.menu
Other
3.15k stars 89 forks source link

Add the possibility to pass {{selected_text}} to commands and URIs #573

Open Schneegans opened 3 months ago

Schneegans commented 3 months ago

Description

I would be cool if the currently selected text was available in commands and URIs.

Affected Desktop Environments

All

Additional Information

On Linux, there is a concept of a primary selection. That's a clipboard which automatically contains the most recently selected text. On Windows we may have to send a Ctrl+C to the active window in order to get the selected text. On macOS? I have no idea 🙂

joh6nn commented 3 months ago

Apps exist to do something similar to this on both Mac and Windows:

So it's at least possible. I'll do my best to find the relevant APIs and/or gross hacks needed to make this work for each platform

ognistik commented 3 months ago

I have a Kando menu for a lot of text transformations (through an Alfred workflow). Currently, before doing the text processing, it just executes a CMD C to copy whatever text is selected (and at the end it executes a CMD V to replace). Alfred also has a way of grabbing selected text by setting a keyboard shortcut and sending selected text as an argument for another action, but in reality it's just copying the text—in a similar way as copying with CMD C. Since Alfred has a clipboard manager feature I can easily "restore" my original clipboard.

I used to use Popclip a lot a while back, but I often felt bothered by the auto popup function on selected text and would activate it with a Shortcut only. Now, the auto popup function on selected text is—in my opinion—the one feature that would be hard to replicate by Kando and could be desirable for users that like this behavior with Popclip. I imagine something like having a menu popup for selected text... though I am not sure if this is too obtrusive.

For the actual passing of the text selection, I highly suspect that Popclip does what Alfred does, copying the text and immediately restoring the previous clipboard (while saving the copied text in a variable to be processed). There's this "transient clipboard" option that Alfred and also some clipboard managers offer which allows to quickly save stuff on a clipboard without making this available to other apps... so by using this, Popclip could be copying text that doesn't even appear in any clipboard manager or user's clipboard. That's my guess, anyways.

It's been a while that I used Popclip so I don't know about this, but could also be that it auto detects if it's copying from an input text field (editable, which can replace selected text), or from a non editable one... this could possibly be useful in a Kando variable as well.

KAGEYAM4 commented 3 months ago

This is what i am using in Linux wl-paste -p | xargs flatpak run dev.mufeed.Wordbook -l -> It takes whatever text was recently selected ( primary clipboard ) and launches the command flatpak run dev.mufeed.Wordbook -l <selected-text>.

Schneegans commented 6 hours ago