Biont / sway-launcher-desktop

TUI Application launcher with Desktop Entry support. Made for SwayWM, but runs anywhere
GNU General Public License v3.0
606 stars 28 forks source link

feat: A helper to clean broken cache entries. #50

Closed WhyNotHugo closed 2 years ago

WhyNotHugo commented 3 years ago

I'd like a script that goes through all cached entries and deletes any that no longer exist (e.g.: deleted desktop entries).

I'm wondering if some user or contributor already has a script that does that.

Biont commented 3 years ago

I like the idea, but it would need to work with any kind of provider. Not every provider is file-based so we cannot make a generic solution for everything. An idea would be to add another validate_cmd to any provider which returns 0 if a given entry is still valid and 1 if it isn't. I guess there would be some sway-launcher-desktop.sh prune command that iterates over the cache file and calls the verify_cmd of the corellating provider of each entry - exposed as template variable {1}.

This could then be set up as a cronjob, pacman hook or something like that.

WhyNotHugo commented 3 years ago

An idea would be to add another validate_cmd to any provider which returns 0 if a given entry is still valid and 1 if it doesn't.

This is the kind of idea I was hoping to hear, sounds like a very simple yet flexible approach.

Biont commented 2 years ago

I created a feature branch that introduces the purge function. It iterates over the current history file and weeds out every entry that does not pass a specified filter callback.

~As of now, this has a couple of limitations:~ ~- untested~ ~- no documentation~ ~- only works on the builtin providers. Parsing a custom PROVIDERS_FILE still needs to be implemented~