Pre-checks
Do similar tools already implement this feature?
I really don't know about that.
I'm willing to go look around, though; but I just wanna start gathering maybe some insight into how best to resolve it: I'm not sure the feature I'm proposing is really all that desirable in the end.
Describe your feature request
I'd like to have the option to instruct fuzzel to not prune away the entries from the cache that aren't found in the latest listing.
However, I know full well that I can work without this, although with some limitation... Maybe it's not really a worthwhile feature. Let's talk about this.
Context/Conceptual example
Well, I use Fuzzel for pretty much every menu I have, it's really just that nice.
Some menus don't always have exactly the same set of options—they may, for example, filter out the "currently selected" option; in which case I have, over time, as many possible sets of items as I have items in total.
Take this specific example:
pactl --format=json list sinks \
| jq --raw-output '.[] | select(.state != "RUNNING") | .name + "\t" + .properties["device.description"]' \
| ifne fuzzel --dmenu --accept-nth=1 --with-nth=2 \
--hide-prompt --cache="$XDG_CACHE_HOME/fuzzel-audio-sink" \
| ifne xargs pactl set-default-sink
Activating this script lists my available audio output devices, filters out the one that's currently "in use", pass that through fuzzel and switches to using the selection (if any) as the primary sink.
Now sometimes, it looks like pactl yields those devices names in a different order, it must be due to some sort of hardware detection mechanism that doesn't always revolve in the same order—it doesn't matter. What matters is: I want to just be clicking the first option pretty much always ;)
I figured fuzzel already has some native feature to help me find the stuff I want: its cache!
In this case, say that I have 3 devices:
headset, some headset
laptop, my laptop's built-in speaker
dock, whatever device is available through my docking station
The problem
When the headset is active, I have a list with [laptop, dock]; when the docking station speaker is active, the list only comprises [headset, laptop]. Every time I select an item, the list it gives fuzzel lacks one element: the currently selected audio sink.
I haven't dug through the code, but by inspecting the cache, I think that fuzzel does something which is, truth be told, quite legitimate: it seems to prune the cache entries that it doesn't find in its input list.
In the case of my audio sink selector, that doesn't quite work for me: the most recently selected item will systematically be deleted the next time I prompt for a new selection!
I have some similar issue where notification actions are subject to the same issue: some actions just aren't available as a response to some notifications, yet I do not want my history of using them to be erased.
Possible resolutions
I could, for example, use a distinct cache for each option: each of headset, laptop, dock could have its own file. I don't like that so much, but that works.
I would love to be able to have it "just work", but I realise I'm asking for an option that would essentially, over time, allow some cache files to grow gigantic: instruct fuzzel to not prune it. Maybe it's really not the ideal solution.
Another possible, presumably quite simple solution, would be adding a flag that gets passed a list of items to simply disregard: I can keep passing my entire list to fuzzel and tell it to not display the currently active audio sink, that'd work as well.
A third option (likely not even worth entertaining here) would be to consider offering some frecency algorithm, which would likely store some of recency indicator (time stamp?) somewhere as part of the cache, and we could in turn use that information to prevent pruning items that were still used quite/most recently.
I really mostly want to gather insight and opinions, I'm pretty sure I'm not the first guy to use fuzzel for menus such as these, and I'm pretty sure I'm missing something but I really couldn't find what.
Thanks again for the excellent tool, and happy New Year!
### Pre-checks
- [x] The [fuzzel.ini](https://codeberg.org/dnkl/fuzzel/src/branch/master/doc/fuzzel.ini.5.scd)
and [fuzzel](https://codeberg.org/dnkl/fuzzel/src/branch/master/doc/fuzzel.1.scd) man pages.
- [x] [Changelog](https://codeberg.org/dnkl/fuzzel/src/branch/master/CHANGELOG.md#unreleased)
of newer and unreleased features
### Do similar tools already implement this feature?
I really don't know about that.
I'm willing to go look around, though; but I just wanna start gathering maybe some insight into how best to resolve it: I'm not sure the feature I'm proposing is really all that desirable in the end.
### Describe your feature request
I'd like to have the option to instruct `fuzzel` to not prune away the entries from the cache that aren't found in the latest listing.
However, I know full well that I can work without this, although with some limitation... Maybe it's not really a worthwhile feature. Let's talk about this.
## Context/Conceptual example
Well, I use Fuzzel for pretty much every menu I have, it's really just *that* nice.
Some menus don't always have exactly the same set of options—they may, for example, filter out the "currently selected" option; in which case I have, over time, as many possible sets of items as I have items in total.
Take this specific example:
```sh
pactl --format=json list sinks \
| jq --raw-output '.[] | select(.state != "RUNNING") | .name + "\t" + .properties["device.description"]' \
| ifne fuzzel --dmenu --accept-nth=1 --with-nth=2 \
--hide-prompt --cache="$XDG_CACHE_HOME/fuzzel-audio-sink" \
| ifne xargs pactl set-default-sink
```
Activating this script lists my available audio output devices, filters out the one that's currently "in use", pass that through `fuzzel` and switches to using the selection (if any) as the primary sink.
Now sometimes, it looks like `pactl` yields those devices names in a different order, it must be due to some sort of hardware detection mechanism that doesn't always revolve in the same order—it doesn't matter. What matters is: I want to just be clicking the first option pretty much always ;)
I figured `fuzzel` already has some native feature to help me find the stuff I want: its cache!
In this case, say that I have 3 devices:
- `headset`, some headset
- `laptop`, my laptop's built-in speaker
- `dock`, whatever device is available through my docking station
### The problem
When the `headset` is active, I have a list with `[laptop, dock]`; when the `dock`ing station speaker is active, the list only comprises `[headset, laptop]`. Every time I select an item, the list it gives `fuzzel` lacks one element: the currently selected audio sink.
I haven't dug through the code, but by inspecting the cache, I think that `fuzzel` does something which is, truth be told, quite legitimate: it seems to prune the cache entries that it doesn't find in its input list.
In the case of my audio sink selector, that doesn't quite work for me: the most recently selected item will systematically be deleted the next time I prompt for a new selection!
I have some similar issue where notification actions are subject to the same issue: some actions just aren't available as a response to some notifications, yet I do not want my history of using them to be erased.
### Possible resolutions
I could, for example, use a distinct cache for each option: each of `headset`, `laptop`, `dock` could have its own file. I don't like that so much, but that works.
I would love to be able to have it "just work", but I realise I'm asking for an option that would essentially, over time, allow some cache files to grow gigantic: instruct `fuzzel` to not prune it. Maybe it's really not the ideal solution.
Another possible, presumably quite simple solution, would be adding a flag that gets passed a list of items to simply disregard: I can keep passing my entire list to `fuzzel` and tell it to not display the currently active audio sink, that'd work as well.
A third option (likely not even worth entertaining here) would be to consider offering some [frecency](https://en.wikipedia.org/wiki/Frecency) algorithm, which would likely store some of recency indicator (time stamp?) somewhere as part of the cache, and we could in turn use that information to prevent pruning items that were still used quite/most recently.
I really mostly want to gather insight and opinions, I'm pretty sure I'm not the first guy to use `fuzzel` for menus such as these, and I'm pretty sure I'm missing something but I really couldn't find what.
---
Thanks again for the excellent tool, and happy New Year!