feat: Allow plugins to signal to deactivate themselves
Necessary when a plugin is unsupported
This commit is contained in:
parent
5ce96c624b
commit
6efad71f0e
3 changed files with 14 additions and 2 deletions
|
|
@ -25,7 +25,11 @@ impl Type for Item {
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
let connection = match Connection::new_session() {
|
let connection = match Connection::new_session() {
|
||||||
Ok(conn) => conn,
|
Ok(conn) => conn,
|
||||||
Err(_) => return,
|
Err(_) => {
|
||||||
|
let mut out = async_stdout();
|
||||||
|
let _ = crate::send(&mut out, PluginResponse::Deactivate);
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut app = App::new(connection, async_stdout());
|
let mut app = App::new(connection, async_stdout());
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,12 @@ impl<O: Write> Service<O> {
|
||||||
gpu_preference,
|
gpu_preference,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report the plugin as finished and remove it from future polling
|
||||||
|
PluginResponse::Deactivate => {
|
||||||
|
self.finished(plugin).await;
|
||||||
|
let _ = self.plugins.remove(plugin);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// When a plugin has exited, the sender attached to the plugin will be dropped
|
// When a plugin has exited, the sender attached to the plugin will be dropped
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,13 @@ pub enum PluginResponse {
|
||||||
Clear,
|
Clear,
|
||||||
/// Close the launcher.
|
/// Close the launcher.
|
||||||
Close,
|
Close,
|
||||||
// Additional options for launching a certain item
|
// Additional options for launching a certain item.
|
||||||
Context {
|
Context {
|
||||||
id: Indice,
|
id: Indice,
|
||||||
options: Vec<ContextOption>,
|
options: Vec<ContextOption>,
|
||||||
},
|
},
|
||||||
|
/// Instruct the launcher service to deactivate this plugin.
|
||||||
|
Deactivate,
|
||||||
// Notifies that a .desktop entry should be launched by the frontend.
|
// Notifies that a .desktop entry should be launched by the frontend.
|
||||||
DesktopEntry {
|
DesktopEntry {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue