feat: add a toolkit crate for both client and pop-launcher-bin
This commit is contained in:
parent
a5c2569654
commit
47852e53cb
12 changed files with 56 additions and 24 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -1075,8 +1075,7 @@ version = "1.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs 4.0.0",
|
"dirs 4.0.0",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"pop-launcher-plugins",
|
"pop-launcher-toolkit",
|
||||||
"pop-launcher-service",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
|
@ -1143,6 +1142,15 @@ dependencies = [
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pop-launcher-toolkit"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"pop-launcher",
|
||||||
|
"pop-launcher-plugins",
|
||||||
|
"pop-launcher-service",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ repository = "https://github.com/pop-os/launcher"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["bin", "plugins", "service"]
|
members = ["bin", "plugins", "service", "toolkit"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
const_format = "0.2.22"
|
const_format = "0.2.22"
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ publish = false
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pop-launcher-plugins = { path = "../plugins" }
|
pop-launcher-toolkit = { path = "../toolkit" }
|
||||||
pop-launcher-service = { path = "../service" }
|
|
||||||
tracing = "0.1.32"
|
tracing = "0.1.32"
|
||||||
tracing-subscriber = { version = "0.3.9", default-features = false, features = ["std", "fmt", "env-filter"] }
|
tracing-subscriber = { version = "0.3.9", default-features = false, features = ["std", "fmt", "env-filter"] }
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
// Copyright 2021 System76 <info@system76.com>
|
// Copyright 2021 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
use pop_launcher_plugins as plugins;
|
use pop_launcher_toolkit::plugins;
|
||||||
use pop_launcher_service as service;
|
use pop_launcher_toolkit::service;
|
||||||
|
|
||||||
use mimalloc::MiMalloc;
|
use mimalloc::MiMalloc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use serde::Deserialize;
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Clone)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
matches: HashMap<String, u32>,
|
matches: HashMap<String, u32>,
|
||||||
queries: Slab<Vec<Definition>>,
|
queries: Slab<Vec<Definition>>,
|
||||||
|
|
@ -29,18 +29,18 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct RawConfig {
|
pub struct RawConfig {
|
||||||
pub rules: Vec<Rule>,
|
pub rules: Vec<Rule>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Rule {
|
pub struct Rule {
|
||||||
pub matches: Vec<String>,
|
pub matches: Vec<String>,
|
||||||
pub queries: Vec<Definition>,
|
pub queries: Vec<Definition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct Definition {
|
pub struct Definition {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub query: String,
|
pub query: String,
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,10 @@ use url::Url;
|
||||||
|
|
||||||
use pop_launcher::*;
|
use pop_launcher::*;
|
||||||
|
|
||||||
use self::config::{Config, Definition};
|
pub use config::{Config, Definition, load};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
|
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
let mut app = App::default();
|
let mut app = App::default();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ mod client;
|
||||||
mod plugins;
|
mod plugins;
|
||||||
|
|
||||||
pub use client::*;
|
pub use client::*;
|
||||||
|
pub use plugins::config;
|
||||||
|
pub use plugins::external::load;
|
||||||
|
|
||||||
use crate::plugins::*;
|
use crate::plugins::*;
|
||||||
use flume::{Receiver, Sender};
|
use flume::{Receiver, Sender};
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize, Clone)]
|
||||||
pub struct PluginConfig {
|
pub struct PluginConfig {
|
||||||
pub name: Cow<'static, str>,
|
pub name: Cow<'static, str>,
|
||||||
pub description: Cow<'static, str>,
|
pub description: Cow<'static, str>,
|
||||||
|
|
@ -32,7 +32,7 @@ pub struct PluginConfig {
|
||||||
pub history: bool,
|
pub history: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize, Clone)]
|
||||||
pub struct PluginBinary {
|
pub struct PluginBinary {
|
||||||
path: Cow<'static, str>,
|
path: Cow<'static, str>,
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ pub struct PluginBinary {
|
||||||
args: Vec<Cow<'static, str>>,
|
args: Vec<Cow<'static, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize)]
|
#[derive(Debug, Default, Deserialize, Clone)]
|
||||||
pub struct PluginQuery {
|
pub struct PluginQuery {
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
// Copyright 2021 System76 <info@system76.com>
|
// Copyright 2021 System76 <info@system76.com>
|
||||||
// SPDX-License-Identifier: MPL-2.0
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
mod config;
|
|
||||||
pub(crate) mod external;
|
pub(crate) mod external;
|
||||||
|
pub mod config;
|
||||||
pub mod help;
|
pub mod help;
|
||||||
|
|
||||||
|
pub use external::load;
|
||||||
|
|
||||||
pub use self::config::{PluginBinary, PluginConfig, PluginPriority, PluginQuery};
|
pub use self::config::{PluginBinary, PluginConfig, PluginPriority, PluginQuery};
|
||||||
pub use self::external::ExternalPlugin;
|
pub use self::external::ExternalPlugin;
|
||||||
pub use self::help::HelpPlugin;
|
pub use self::help::HelpPlugin;
|
||||||
|
|
|
||||||
14
src/lib.rs
14
src/lib.rs
|
|
@ -44,13 +44,13 @@ pub type Generation = u32;
|
||||||
/// u32 value defining the indice of a slot.
|
/// u32 value defining the indice of a slot.
|
||||||
pub type Indice = u32;
|
pub type Indice = u32;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub struct ContextOption {
|
pub struct ContextOption {
|
||||||
pub id: Indice,
|
pub id: Indice,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub enum GpuPreference {
|
pub enum GpuPreference {
|
||||||
Default,
|
Default,
|
||||||
NonDefault,
|
NonDefault,
|
||||||
|
|
@ -65,7 +65,7 @@ pub enum IconSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sent from a plugin to the launcher service.
|
/// Sent from a plugin to the launcher service.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub enum PluginResponse {
|
pub enum PluginResponse {
|
||||||
/// Append a new search item to the launcher.
|
/// Append a new search item to the launcher.
|
||||||
Append(PluginSearchResult),
|
Append(PluginSearchResult),
|
||||||
|
|
@ -92,7 +92,7 @@ pub enum PluginResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Search information from a plugin to be sorted and filtered by the launcher service.
|
/// Search information from a plugin to be sorted and filtered by the launcher service.
|
||||||
#[derive(Debug, Default, Deserialize, Serialize)]
|
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
|
||||||
pub struct PluginSearchResult {
|
pub struct PluginSearchResult {
|
||||||
/// Numeric identifier tracked by the plugin.
|
/// Numeric identifier tracked by the plugin.
|
||||||
pub id: Indice,
|
pub id: Indice,
|
||||||
|
|
@ -111,7 +111,7 @@ pub struct PluginSearchResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sent to the input pipe of the launcher service, and disseminated to its plugins.
|
// Sent to the input pipe of the launcher service, and disseminated to its plugins.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub enum Request {
|
pub enum Request {
|
||||||
/// Activate on the selected item.
|
/// Activate on the selected item.
|
||||||
Activate(Indice),
|
Activate(Indice),
|
||||||
|
|
@ -132,7 +132,7 @@ pub enum Request {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sent from the launcher service to a frontend.
|
/// Sent from the launcher service to a frontend.
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||||
pub enum Response {
|
pub enum Response {
|
||||||
// An operation was performed and the frontend may choose to exit its process.
|
// An operation was performed and the frontend may choose to exit its process.
|
||||||
Close,
|
Close,
|
||||||
|
|
@ -153,7 +153,7 @@ pub enum Response {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Serialized response to launcher frontend about a search result.
|
/// Serialized response to launcher frontend about a search result.
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct SearchResult {
|
pub struct SearchResult {
|
||||||
/// Numeric identifier tracked by the plugin.
|
/// Numeric identifier tracked by the plugin.
|
||||||
pub id: Indice,
|
pub id: Indice,
|
||||||
|
|
|
||||||
12
toolkit/Cargo.toml
Normal file
12
toolkit/Cargo.toml
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "pop-launcher-toolkit"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
description = "A wrapper around pop-launcher, pop-launcher-service and pop-launcher-plugins types for writing plugins and frontends for pop-launcher."
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
pop-launcher-plugins = { path = "../plugins"}
|
||||||
|
pop-launcher-service = { path = "../service"}
|
||||||
|
pop-launcher = { path = "../" }
|
||||||
10
toolkit/src/lib.rs
Normal file
10
toolkit/src/lib.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright 2021 System76 <info@system76.com>
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
pub use pop_launcher_service::{
|
||||||
|
self as service,
|
||||||
|
load::from_path as load_plugin_from_path,
|
||||||
|
load::from_paths as load_plugins_from_paths
|
||||||
|
};
|
||||||
|
pub use pop_launcher_plugins as plugins;
|
||||||
|
pub use pop_launcher as launcher;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue