Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions plugins/applications/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ Config(
// {} is replaced with the command in the desktop entry
args: "-e {}",
)),

// Whether to prioritize actions or applications
// Could be ActionsFirst (default), ApplicationsFirst, or NoPriority
entry_priority: ActionsFirst,
)
```
22 changes: 18 additions & 4 deletions plugins/applications/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pub struct Config {
max_entries: usize,
terminal: Option<Terminal>,
preprocess_exec_script: Option<PathBuf>,

#[serde(default)]
entry_priority: EntryPriority,
}

#[derive(Deserialize)]
Expand All @@ -19,13 +22,22 @@ pub struct Terminal {
args: String,
}

#[derive(Deserialize, Default)]
pub enum EntryPriority {
#[default]
ActionsFirst,
ApplicationsFirst,
NoPriority,
}

impl Default for Config {
fn default() -> Self {
Self {
desktop_actions: false,
max_entries: 5,
preprocess_exec_script: None,
terminal: None,
entry_priority: EntryPriority::default(),
}
}
}
Expand Down Expand Up @@ -200,10 +212,12 @@ pub fn get_matches(input: RString, state: &State) -> RVec<Match> {

let mut score = (name_score * 10 + desc_score + keyword_score) - entry.offset;

// prioritize actions
if entry.is_action {
score *= 2;
}
// Apply priority
score *= match (&state.config.entry_priority, entry.is_action) {
(EntryPriority::ActionsFirst, true) => 2,
(EntryPriority::ApplicationsFirst, false) => 2,
_ => 1,
};

// Score cutoff
if score > 0 {
Expand Down