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

[REQUEST] Keep selected item position after selection #1064

Closed
s0la opened this issue Mar 4, 2020 · 21 comments
Closed

[REQUEST] Keep selected item position after selection #1064

s0la opened this issue Mar 4, 2020 · 21 comments
Milestone

Comments

@s0la
Copy link

s0la commented Mar 4, 2020

Hi!

First, I want to express my honest appreciation for this software, I use it as main "gui" way of interacion in workflow, as well as in my project called ORW..

So, I have kinda really specific use case..
Few of my scripts have selection feature, which allows user to select multiple items on which following operation will be performed.
I recently found out multi-select option with dmenu mode, but my scripts are already written to work with rofi's "default" mode, and some of them are few hundred lines long, so it would be quite time consuming to rewrite whole logic to adjust them for dmenu mode, and beside that, every time I select something using dmenu, rofi launces again, which looks like a "blink".

So, what I would like to have is key-binding to keep "selected-item" in its place after I press it (like shift+Enter does, but with default Enter effect - no need for selection logic, my scritps are already handling that), because current behaviour returns it to first item, which means user need to select next item from the beggining..

If this feature is too complex to implement, or you find its application to be very marginal, therefore not worth of your time and effort, I'll totally understand. It won't be a deal breaker by any means, but it will curtainlly make my use case a lot more convenient :)

To better illustrate situation, I provided screenshot:
rofi_selection_fix

Here is also demo of one of my scripts in action:
file_manager_demo

Thanks in advance! :)

Version: 1.5.4-1

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 4, 2020

This can be done already.
Using -selected-row and -format option

rofi -dmenu -format 'i s ' -selected-row 6

this selects row 6. It returns the row index + entry when an item is selected.. then you pass row index +1 to -selected-row on the next call.

@s0la
Copy link
Author

s0la commented Mar 5, 2020

The thing is, I would need something like this without using -dmenu. As I mentioned in initial comment, I don't use rofi with -dmenu, I use it with -modi, specifing script I want to run, and it stays open until I explicitly close it, so it's not possible to specify row index while rofi is running. That's the reason I suggested key-binding solution, which invokes "Enter action", leaving the current state as it is.

As I alrady said, it's not of any crutial importance, so if you find it to be too much of a hassle to implement, feel free to leave it closed :)
Thanks anyway! :)

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Mar 5, 2020

Aah sorry I missed that you are using script mode. (never seen it mentioned as 'default mode' as dmenu was there first :D)). I though you talked about 'stock dmenu ' mode.

Can you please add the version you are using. this will help people place the issue in a few years.

@DaveDavenport DaveDavenport reopened this Mar 5, 2020
@s0la
Copy link
Author

s0la commented Mar 5, 2020

Sorry for the confusion, I should said script mode right from the start, my bad :D

Ofc, sorry about that as well. I'm running the latest version, 1.5.4-1, I'll add that to initial comment.
Thanks for taking this into consideration! :)

@joshpetit
Copy link

Is there any plan or already existing implementation for allowing users to keep the selected row active? This would be a nice feature. Right now I'm planning on moving the most recently selected item to the top to fix the problem.

@DaveDavenport
Copy link
Collaborator

Added a 'keep-selection' flag in git. Example here: https://github.com/davatorium/rofi/blob/next/Examples/test_script_mode_color.sh

@DaveDavenport DaveDavenport added this to the 1.7.4 milestone Jul 9, 2022
@s0la
Copy link
Author

s0la commented Jul 17, 2022

Hey bud, these are great news, it works amazingly!! I already added it to my script implementation, I'm super happy with the result.. Also, thanks for provided example, I wasn't aware those customization/tweaks are possible, it's super cool!! :)
I really appreciate your effort, rofi became essential tool in my workflow, and thanks again for taking the time to address this minor (for me very useful) feature!

Cheers!! :)

@s0la
Copy link
Author

s0la commented Jul 30, 2022

Hey, I noticed one thing.. When I enable keep-selection as you described, it works perfectly regarding position, but it seems like it's also keeping my last search in the prompt.. That means when I select an item from a list which is supposed to generate a new content, it being filtered by remembered query and initial results are often empty until I delete the searched term..

Now, I'm not sure if this is how it's suppose to work (keeping position also means keeping last search query in the input), or simply a bug.. If it turns out to be a bug, and if it's something too time consuming for you, you don't have to bother as far as I'm concerned, I can live with this by removing query every time.. I was just wondering if I produced this misbehavior with some of my scripts, or it's by design :)

Anyway, thank you once again for everything you did with Rofi in general, and especially regarding this specific issue!!

@DaveDavenport
Copy link
Collaborator

does it make sense to keep the selection when the content changes?

@DaveDavenport
Copy link
Collaborator

p.s. there is also a 'new-selection' option now, maybe that is better. I can add the clear-input if needed.

@s0la
Copy link
Author

s0la commented Jul 30, 2022

well no, but in my music library script, I have directory structure (like /genre/band/album/songs) and the songs, which are at the end of the path.. Now the problem is that I want keep-selection to be enabled when I'm choosing songs, because if I have a lot of songs, without keeping position I'll have to start all the way from the beginning for every song (or any other file in general, in my other scripts), which is like factorial movement.. That why keeping position help a lot.. But I don't want to keep the position while traversing through directory structure, only in the files/songs, but the keep-selection option is always on..

Hope the given scenario makes sense, if not, let me know and I'll try to clarify it with a better example :)

@DaveDavenport
Copy link
Collaborator

I am not sure I follow, if content changes, then the 'selection' may move (as it is position based) same if content stays the same but filter changes.

@DaveDavenport
Copy link
Collaborator

changed it so it clears the input
but I am not sure this is what you want.

@s0la
Copy link
Author

s0la commented Jul 30, 2022

I don't think the position is the problem, I won't mind if the selected item is in the middle of the next list, I can move it to the beginning or simply start typing to match what I'm looking for.. The problem is that if there is the filter query remembered, it will ignore anything that doesn't match, which will often leave an empty list, if that makes more sense :)

Let me try the latest update, and also new-position, and I'll let you know if it fixes my issues.. Also, thanks a lot for such immediate response, I really appreciate it! :)

@s0la
Copy link
Author

s0la commented Jul 30, 2022

Hmm, I'm trying to build it, but I'm getting:

No rule to make target 'themes/iggy.jpg', needed by 'all-am'.

error, are you familiar with that, or maybe know how to fix it?

@DaveDavenport
Copy link
Collaborator

build fine here in both autotools/ninja and that parts works on several CI.

@s0la
Copy link
Author

s0la commented Jul 30, 2022

Ok, I managed to build it with ninja, sorry about that..

But the behavior seems unchanged.. The "new-selection" keeps the input clean but doesn't remember the position, and "keep-selection" does the opposite - keeps position and input as well

this is what I print for every list:

printf "\0keep-selection\x1ftrue\n"
the code to generate the content/list..

Do I need some specific syntax to keep the input clean as well?

@DaveDavenport
Copy link
Collaborator

DaveDavenport commented Jul 30, 2022

confused? keep-selection should clean the input. keep-selection+new-selection overrides the selection.
It works for me with the included example.
(keep-selection/new-selection is not sticky, and needs to be set every time.)

@s0la
Copy link
Author

s0la commented Jul 30, 2022

Oh, sorry, the input cleaning works great now, and it still keeps the position..
The reason I didn't see the changes right away is because I didn't notice the rofi used by that script was actually a stable version, not the one I just complied, so that's totally on me.. Once I changed the version, it all worked perfectly :)

Thank you once again for such a fast response, and for immediately implementing a fix.. And, ofc, sorry if I wasted your time more than necessary, again, really appreciate all your efforts! :)

Thanks!

@s0la
Copy link
Author

s0la commented Jul 31, 2022

Hey, sorry for bothering, one more thing..
First of all, this is not related to this request, but I'd rather asked it here than opening a new one, since I think the answer should be short and simple, so it's not worth it..

So, since there is a calc function that can be used in rasi config files, is there any way I can use variables defined withing that config in calc function? I found a similar question, and it mentions environment variables, but I'm not sure how to use those either, so any information regarding this subject would be much appreciated :)

@DaveDavenport
Copy link
Collaborator

please don't ask questions in the issue tracker on an unrelated issue. Its against the rules. (this topic is now locked).
Use the discussion forum for questions.

@davatorium davatorium locked as off-topic and limited conversation to collaborators Jul 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants