20
850
Fork
You've already forked fuzzel
83

Option to disable pruning the cache #719

Open
opened 2025年12月31日 14:17:42 +01:00 by ccjmne · 3 comments

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!
Author
Copy link

For what it's worth, I just went ahead and used:

--cache="$XDG_CACHE_HOME/fuzzel/$(basename 0ドル)/$(pactl get-default-sink)"

Which obviously works splendidly. Maybe it really is the best—though now, I have entire caches that won't be pruned if and when an entry becomes obsolete ;)

For what it's worth, I just went ahead and used: ```sh --cache="$XDG_CACHE_HOME/fuzzel/$(basename 0ドル)/$(pactl get-default-sink)" ``` Which obviously works splendidly. Maybe it really is the best—though now, I have entire *caches* that won't be pruned if and when an entry becomes obsolete ;)
Collaborator
Copy link

Fuzzel already has an option called --with-nth that selects a column from the input to display. I checked to see if that could help to ignore a line from the input. Here trying to ignore the first line because there's nothing between the \t and \n and I've asked it to select the second column:

echo -e "❌\t\n👍\tYes\n👎\tNo" | fuzzel --dmenu --with-nth 2 --dmenu

That doesn't work though: Fuzzel still displays an empty line.

I tried omitting the second column completely, but that exposes a bug in Fuzzel! It displays {2} instead-- accidentally exposing an implementation detail of Fuzzel:

 echo -e "❌\n👍\tYes\n👎\tNo" | fuzzel --dmenu --with-nth 2 --dmenu

Maybe the --width-nth behavior should be changed to ignore empty columns.

Fuzzel already has an option called `--with-nth` that selects a column from the input to display. I checked to see if that could help to ignore a line from the input. Here trying to ignore the first line because there's nothing between the \t and \n and I've asked it to select the second column: ``` echo -e "❌\t\n👍\tYes\n👎\tNo" | fuzzel --dmenu --with-nth 2 --dmenu ``` That doesn't work though: Fuzzel still displays an empty line. I tried omitting the second column completely, but that exposes a bug in Fuzzel! It displays `{2}` instead-- accidentally exposing an implementation detail of Fuzzel: ``` echo -e "❌\n👍\tYes\n👎\tNo" | fuzzel --dmenu --with-nth 2 --dmenu ``` Maybe the `--width-nth` behavior should be changed to ignore empty columns.
Author
Copy link

Oh, that's interesting, leveraging the --accept-nth/--with-nth pair and removing empty entries!

Oh, that's interesting, leveraging the `--accept-nth`/`--with-nth` pair and removing empty entries!
Sign in to join this conversation.
No Branch/Tag specified
master
gnome-support
releases/1.14
issue-319-window-switching
issue-561-nord-theme-only
resvg-filtering-take-2
resvg-filtering
releases/1.13
rehanzo-dont-ignore-execute-648
keybinds-overwrite
issue-561-refresh-theme
ci-automated-testing
reenable-legacy-icons
releases/1.12
test-coverage-for-fzf-caching
releases/1.11
releases/1.10
releases/1.9
releases/1.8
releases/1.7
releases/1.6
releases/1.5
releases/1.4
releases/1.3
releases/1.2
releases/1.1
releases/1.0
1.14.1
1.14.0
1.13.1
1.13.0
1.12.0
1.11.1
1.11.0
1.10.2
1.10.1
1.10.0
1.9.2
1.9.1
1.9.0
1.8.2
1.8.1
1.8.0
1.7.0
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.4.2
1.4.1
1.4.0
1.3.0
1.2.0
1.1.0
1.0.1
1.0.0
0.9.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fuzzel#719
Reference in a new issue
dnkl/fuzzel
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?