davatorium / rofi

Rofi: A window switcher, application launcher and dmenu replacement
https://davatorium.github.io/rofi/
Other
13.04k stars 609 forks source link

combi: major-key the sorting based on frequency (or frecency) instead of modi #606

Open unhammer opened 7 years ago

unhammer commented 7 years ago

Version

Version: 1.3.1

Configuration

https://gist.github.com/unhammer/a2484e704cdc05395d997ad7cd072490

Launch Command

rofi -modi combi -show combi -combi-modi "drun,run,ssh,window"

Steps to reproduce

What behaviour you see

What behaviour you expect to see

DaveDavenport commented 7 years ago

This is not a trivial fix, as different modi have their own history and sorting. Currently it sorts on frequency (wth is frecency?) within each mode.

I agree it would be nice feature to have, but I don't see a solution that won't require major overhaul to implement this right (tm). (A hack might be to give modi its own history, but this also has it limitations/issues.).

unhammer commented 7 years ago

This is not a trivial fix, as different modi have their own history and sorting. Currently it sorts on frequency (wth is frecency?) within each mode.

Frecency:

I agree it would be nice is this could be nicer, but I don't see a solution that won't require major overhaul to implement this right (tm). (A hack might be to give modi its own history, but this also has it limitations/issues.).

I wouldn't mind having a history specific to the combi modi – it'd be a lot better than having my most frequent command always in second place :)

DaveDavenport commented 7 years ago

Aah thanks. Kinda assumed it a typo. :smile: always good to learn something new.

Somethings:

unhammer commented 7 years ago
  • How to handle multiple calls to different combi combinations?

Yeah, that would be the downside to having one history for drun,run,window and one for window,drun. Do people do this kind of thing often enough that it's an issue?

  • Personally I use it like this: -combi-modi window, drun,run If I type firefox I want to launch firefox, if i have firefox open, I want to switch to the open firefox. The current behaviour does this.

Aha, I rarely use window so I didn't think of that. I can't think of a good solution apart from Yet Another switch -prioritize window which would put all the window entries first, then the merge of drun,run.


OTOH, although it'd require more changes to the code, maybe the Right solution is to keep a history for drun, run, window (~/.cache/rofi.druncache, ~/.cache/rofi-3.runcache, …) but read them all into a merged list (keeping track of their modes in the struct), so one can e.g.

cmp(a, b) =
       if (prioritized(a->mode) && !prioritized(b->mode)) return 1
  else if (!prioritized(a->mode) && prioritized(b->mode)) return -1
  else if(a->freq != b->freq) return a->freq - b->freq
  else return strcmp(a->name, b->name)