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

FR: Plugin could catch "user selection" + let Keypirinha stay open after execution #362

Closed
Tagirijus opened this issue Feb 4, 2019 · 5 comments

Comments

@Tagirijus
Copy link

Hey there,

while I was looking for a good way to search my database of presets for synths and effects for my music software I found Keypirinha and its capability to search with the FileCatalog plugin certain filetypes and folders only AND start a drag and drop event, when the user drags a found item from the Keypirinha list.

Now I wanted to start to write an own plugin, which could also maybe search for an audio file with the same name before the file-extension and play it. Example: a preset is called bass_deep.fst and then the Python script could look for bass_deep.mp3 and play it or so on. The point is: I could not find a good point where a Keypirinha plugin could call such a method. 1. Either it would be cool, if it could be called when the user just selects an item (without executing it!) - maybe a new method for a plugin called on_select() or so, 2. or maybe it would be an option to put this into on_execute() of a Keypirinha plugin. In the later case I would love, if there would be an option to let Keypirinha stay open with the actual search and found items and the actual selection - that way I could just execute the found items and listen through them, till I find seomthing useful and start a drag an drop (to use the item and close Keypirinha).

In summary:

  1. Would it be possible to somehow embed an option for plugin writers to let a method call, when the user only selects an item?

  2. Would it be possible to somehow embed an option for plugin writers to let Keypirinha stay open after executing an item?

Thanks for all your help! :)

@Tagirijus
Copy link
Author

By the way, since I did not mention it already: I already came up with some kind of "start". I already have some kind of plugin, which can find presets and play them on execution.

The problem of this issue still exists: Keypirinha closes after that, making it hard to keep track of which preset I listened to. So still: an option to let Keypirinha stay open OR giving plugins an "on_select()" method would be really great (and I think not hard to implement, right?).

Thanks for your help! (=

@ueffel
Copy link

ueffel commented Jun 25, 2019

Maybe you can try something like this:
Workflow:

  • Search item
  • Press TAB or Enter on selected item, it starts playing the file, while offering to do something with the selected file like copy its path (Keypirinha stays open of course)
  • Pressing BACKSPACE goes back to the result list where you can select another result

Implementation pointers:

  • Catalog your items with loop_on_suggest=True and args_hint=kp.ItemArgsHint.REQUIRED in on_catalog
  • In on_suggest start playing the items_chain[0] which is your selected result and create some items like "copy path" or anything you want to do with the result and set them as suggestion with self.set_suggestions (you have to set the path of the result as data_bag for the "copy path" item because in on_execute you only get a single item, not the items_chain)
  • in on_execute get the data_bag of the "copy path" item the get the path of the selected and set_clipboard
  • make sure you stop playing in on_deactivated and on_suggest

@Tagirijus
Copy link
Author

Hey Steffen. Thanks for your reply. I will try to dig into it and come back to this topic later! Thank you for your idea. (=

@Tagirijus
Copy link
Author

Tagirijus commented Jun 25, 2019

Ok, I managed to do a playback after hitting Tab so that at least Keypirinha stays open. Next problem is: when going back with Backspace, the selected result is on the top and the cursor / selection is on the top as well, unfortunately. Is there a way to avoid this?

Edit:
Forget it, I found out that with args_hint=kp.ItemArgsHint.REQUIRED Keypirinha also stays open and plays back the file on pressing enter.

Now I will see if I can get anything useful out of this.

@polyvertex
Copy link
Member

Closing this due to no activity

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

No branches or pull requests

3 participants