Skip to content

Conversation

@peppidesu
Copy link

Issue #14 discussed this feature before, but the branch the maintainer mentioned is out of date by 74 commits.

This pull request implements recency bias into the applications plugin, meaning recently / commonly searched applications will be prioritized. The history file is stored in $HOME/.cache/anyrun-applications-history. The maximum number of entries can be changed in the config file using history_size (see README.md).

Recency bias is only applied if the other score components are not 0 (to prevent unrelated results showing up) and when the input field is empty.

@AsriFox
Copy link

AsriFox commented Nov 27, 2023

That sounds amazing!
Maybe it should be implemented as a separate plugin, though? See #87 and https://github.com/anyrun-org/plugin-applications.

@ra1nb0w
Copy link

ra1nb0w commented Oct 3, 2025

Any update on this useful feature?

Copy link
Collaborator

@Kirottu Kirottu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the PR is quite old, it needs a rebase for me to try it out. Alongside with the other comments that should be addressed.

pub fn load() -> Self {

let path = format!(
"{}/.cache/anyrun-applications-history",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ~/.cache/anyrun/applications-history in line with what the nix-run plugin uses.


let path = format!(
"{}/.cache/anyrun-applications-history",
env::var("HOME").expect("Unable to determine HOME directory")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer $XDG_CACHE_HOME, and use $HOME/.cache as a fallback.

desktop_actions: false,
max_entries: 5,
terminal: None,
history_size: 50,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an optional, in a way that None will disable the history alltogether.


State { config, entries }
let history = history::History::load();
println!("Loaded {} history entries", history.count());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be eprintln!("[applications] ...", ...);

let mut score = (app_score * 25 + keyword_score) - entry.offset;
let history_score = state.history.get_entry_info(entry).map(|(index, count)| {
let recency_bias = i64::max(5-index as i64, 0);
(count as i64 + recency_bias) * 20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the weighting has changed recently, this likely needs different weighting to make it work properly.

@peppidesu
Copy link
Author

Hi, i did a rebase recently for my personal fork which includes this feature. I first want to make some improvements on this because the current algorithm is quite naive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants