diff --git a/plugins/applications/README.md b/plugins/applications/README.md index c6f572a..83f872e 100644 --- a/plugins/applications/README.md +++ b/plugins/applications/README.md @@ -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, ) ``` diff --git a/plugins/applications/src/lib.rs b/plugins/applications/src/lib.rs index 0278cae..1ded774 100644 --- a/plugins/applications/src/lib.rs +++ b/plugins/applications/src/lib.rs @@ -11,6 +11,9 @@ pub struct Config { max_entries: usize, terminal: Option, preprocess_exec_script: Option, + + #[serde(default)] + entry_priority: EntryPriority, } #[derive(Deserialize)] @@ -19,6 +22,14 @@ pub struct Terminal { args: String, } +#[derive(Deserialize, Default)] +pub enum EntryPriority { + #[default] + ActionsFirst, + ApplicationsFirst, + NoPriority, +} + impl Default for Config { fn default() -> Self { Self { @@ -26,6 +37,7 @@ impl Default for Config { max_entries: 5, preprocess_exec_script: None, terminal: None, + entry_priority: EntryPriority::default(), } } } @@ -200,10 +212,12 @@ pub fn get_matches(input: RString, state: &State) -> RVec { 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 {