Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefill search query from Clipboard #123

Closed
sepich opened this issue Sep 21, 2016 · 12 comments
Closed

Prefill search query from Clipboard #123

sepich opened this issue Sep 21, 2016 · 12 comments

Comments

@sepich
Copy link

sepich commented Sep 21, 2016

It would be nice (at least for me ;) to have some simple logic on_open of LaunchBox:

  • check if Clipboard holds one word only, and use it as query then
  • possibly also trim this "word" from spaces on both ends

Reading API docs, it looks like there is no possibility to create such as a plugin. What are the chances to have it implemented as core feature then?

@ueffel
Copy link

ueffel commented Sep 21, 2016

there is the on_activated method that gets called when the KP launchbox is opened.
but i dont think it is possible for a plugin to set the content of the launchbox, to prefill

@sepich
Copy link
Author

sepich commented Sep 21, 2016

Thanks, what i actually was unable to find - is some keypirinha.set_query() method to change current LaunchBox query from inside the plugin. Could you please point me to it?

@ueffel
Copy link

ueffel commented Sep 21, 2016

i dont think that is possible for a plugin. for one it collides with the retain_last_search setting of the core application.
maybe there is a possibility to add that functionally to the kp core. but thats up to @polyvertex

@sepich
Copy link
Author

sepich commented Sep 21, 2016

Actually if it is possible for plugin to push results on_activated, when there were no query yet - that's also ok. Haven't thought about that.

@ueffel
Copy link

ueffel commented Sep 21, 2016

i'm pretty sure that on_suggest isn't called for the empty launchbox, but check that out first. if it doesn't work, you could try to call set_suggestions in the on_activated method. Maybe that works for you.
As a side note there is the chat room for keypirinha @ https://gitter.im/Keypirinha/Keypirinha thats a better place for this discussion i think.

@polyvertex
Copy link
Member

It is not possible for a plugin to change the state of the search as it would give too much power to them. For example, what would happen if two plugins try to change the content of the edit box?

Perhaps a solution lies somewhere else but for that I would need more info about the reason(s) of your request.

@polyvertex
Copy link
Member

Ah I realized I only partly answered to this regarding the following of the discussion.

I confirm that on_suggest isn't called for empty searches, but I suspect you might be successful by calling set_suggestions from the on_activated method. IIRC the code allows that so you should give it a shot :)

@polyvertex
Copy link
Member

@sepich Have you managed to achieve what you wanted?

@sepich
Copy link
Author

sepich commented Sep 25, 2016

I've managed to install KP and write a simple plugin using your SDK. Thanks for detailed docs.
But calling set_suggestions from the on_activated does not lead to actually showing them. Result is the same blank string of query entry, without results.
If i push the same array to set_catalog - they are appended to Catalog successfully.

I would need more info about the reason(s) of your request

Mostly workflow is to copy hostname from Monitoring, and then connect to it. But monitoring has only hostname, and to connect i need fqdn. So i've just wanted to reduce one step in workflow (Ctrl-V). I understand that it could be useful for me only, that's why i intrested to get it as plugin on first hand, and not as core feature. Because i also want to do some custom logic on clipboard content to decide - use it as query or not.

P.S

It is not possible for a plugin to change the state of the search as it would give too much power to them.

I do see a lot of comments like that from you in different issues. I believe that's wrong point.

As a side note, may the plugin developer absolutely wishes to crash the application anyway,
Python and Keypirinha both offer numerous ways to do that too.

That one from here is much better. It is up to user to decide which plugins to use, and which ones are buggy. And devs should have as much possibilities to write some workflow as possible. If they want to write buggy plugin - they would be able to do it even with most restricted API. Ability to shoot in the foot - is not a show stopper for internal API 😉

@polyvertex
Copy link
Member

A while ago I considered adding an extra hotkey to do exactly that: pop up the LaunchBox then immediately paste the content of the clipboard into it if it happens to be some text so a search is started automagically from it. It seems that it would perfectly address your problem.

Regarding your P.S. part, again, by design, plugins won't be able to change the state of the application directly. They can only make suggestions (in its general sense) about what to do and it will be up to the application to handle them or not. That, by extension, allows to give full power to the end-user, not the developer, even if they happen to be the same person. That does not make the API less flexible, that just allows the application to offer a better user experience. In that regard, the key question was: For example, what would happen if two plugins try to change the content of the edit box?

@polyvertex
Copy link
Member

hotkey_paste setting added in v2.9.7

@alpemreelmas
Copy link

alpemreelmas commented Nov 5, 2024

hotkey_paste setting added in v2.9.7

Can we see list of the history ?
It would be awesome, If there is something like that, I do not know.
Ditto is not comfortable one. I'm talking completely replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants