Skip to content

Commit c73e507

Browse files
committed
refactor: move plugins into their own crates
1 parent edab552 commit c73e507

File tree

36 files changed

+417
-133
lines changed

36 files changed

+417
-133
lines changed

Cargo.lock

Lines changed: 135 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[workspace]
2-
members = ["kal", "kal-*"]
3-
exclude = ["kal-ui"]
2+
members = ["kal", "kal-config", "kal-plugin", "kal-plugins/*"]
43
resolver = "2"
54

65
[profile.release]
76
codegen-units = 1 # Allows LLVM to perform better optimization.
87
lto = true # Enables link-time-optimizations.
9-
opt-level = "s" # Prioritizes small binary size. Use `3` if you prefer speed.
8+
opt-level = "s" # Prioritizes small binary size.
109
panic = "abort" # Higher performance by disabling panic handlers.
1110
strip = true # Ensures debug symbols are removed.
1211

@@ -21,3 +20,9 @@ anyhow = "1"
2120
nucleo-matcher = "0.3"
2221
strum = "0.26"
2322
async-trait = "0.1"
23+
windows = "0.59"
24+
rfd = { version = "0.15", default-features = false }
25+
url = "2.5"
26+
serialize-to-javascript = "0.1"
27+
smol = "2.0"
28+
percent-encoding = "2.3"

kal-plugins/app-launcher/Cargo.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[package]
2+
name = "kal-plugin-app-launcher"
3+
version = "0.2.0"
4+
description = "App launcher plugin for kal."
5+
authors = ["Amr Bashir <[email protected]>"]
6+
repository = "https://github.com/amrbashir/kal"
7+
license = "MIT"
8+
edition = "2021"
9+
10+
[dependencies]
11+
kal-config = { path = "../../kal-config" }
12+
kal-utils = { path = "../../kal-utils" }
13+
kal-plugin = { path = "../../kal-plugin" }
14+
anyhow.workspace = true
15+
async-trait.workspace = true
16+
serde.workspace = true
17+
toml.workspace = true
18+
smol.workspace = true
19+
tracing.workspace = true
20+
notify-debouncer-mini = "0.6.0"
21+
notify = "8.0.0"
22+
23+
24+
[target.'cfg(target_os = "windows")'.dependencies.windows]
25+
workspace = true
26+
features = [
27+
"Win32_Foundation",
28+
"Win32_Storage_FileSystem",
29+
"Win32_UI_Shell",
30+
"Win32_System_Com",
31+
"Win32_Storage_Packaging_Appx",
32+
"Management_Deployment",
33+
"ApplicationModel",
34+
"Foundation_Collections",
35+
"deprecated",
36+
]

kal/src/plugins/app_launcher/mod.rs renamed to kal-plugins/app-launcher/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ use std::sync::{Arc, Mutex};
33

44
use kal_config::Config;
55
use kal_plugin::{IntoResultItem, PluginQueryOutput, ResultItem};
6+
use kal_utils::IteratorExt;
67
use notify::RecommendedWatcher;
78
use notify_debouncer_mini::Debouncer;
89
use serde::{Deserialize, Serialize};
910
use windows::ApplicationModel::PackageCatalog;
1011

11-
use crate::utils::IteratorExt;
12-
1312
#[cfg(windows)]
1413
mod packaged_app;
1514
mod program;

kal/src/plugins/app_launcher/packaged_app.rs renamed to kal-plugins/app-launcher/src/packaged_app.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::ffi::OsString;
22
use std::path::PathBuf;
33

4-
use kal_plugin::{Action, IntoResultItem, ResultItem};
4+
use kal_plugin::{Action, BuiltinIcon, Icon, IntoResultItem, ResultItem};
5+
use kal_utils::StringExt;
56
use windows::core::{w, HSTRING, PCWSTR};
67
use windows::ApplicationModel::{
78
Package, PackageCatalog, PackageInstallingEventArgs, PackageUninstallingEventArgs,
@@ -16,9 +17,6 @@ use windows::Win32::Storage::Packaging::Appx::{
1617
use windows::Win32::System::Com::{CoCreateInstance, CLSCTX_ALL, STGM_READ};
1718
use windows::Win32::UI::Shell::{SHCreateStreamOnFileEx, SHLoadIndirectString};
1819

19-
use crate::icon::{BuiltinIcon, Icon};
20-
use crate::utils::{self, StringExt};
21-
2220
const MS_RESOURCE: &str = "ms-resource:";
2321

2422
#[derive(Debug, PartialEq, Eq)]
@@ -62,18 +60,18 @@ impl PackagedApp {
6260
let args_ = args.to_string();
6361
let open = Action::primary(move |_| {
6462
let path = format!("shell:AppsFolder\\{}", appid);
65-
utils::execute_with_args(path, &args_, false, false)
63+
kal_utils::execute_with_args(path, &args_, false, false)
6664
});
6765

6866
let appid = self.appid.clone();
6967
let args_ = args.to_string();
7068
let open_elevated = Action::open_elevated(move |_| {
7169
let path = format!("shell:AppsFolder\\{}", appid);
72-
utils::execute_with_args(path, &args_, true, false)
70+
kal_utils::execute_with_args(path, &args_, true, false)
7371
});
7472

7573
let location = self.location.clone();
76-
let open_location = Action::open_location(move |_| utils::open_dir(&location));
74+
let open_location = Action::open_location(move |_| kal_utils::open_dir(&location));
7775

7876
let tooltip = format!("{}\n{}", self.name, self.location.display());
7977

kal/src/plugins/app_launcher/program.rs renamed to kal-plugins/app-launcher/src/program.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ use std::ffi::{OsStr, OsString};
22
use std::path::{Path, PathBuf};
33
use std::time::Duration;
44

5-
use kal_plugin::{Action, IntoResultItem, ResultItem};
5+
use kal_plugin::{Action, Icon, IntoResultItem, ResultItem};
6+
use kal_utils::{ExpandEnvVars, StringExt};
67
use smol::prelude::*;
78

89
use super::App;
9-
use crate::icon::Icon;
10-
use crate::utils::{self, ExpandEnvVars, StringExt};
1110

1211
#[derive(Debug)]
1312
pub struct Program {
@@ -27,7 +26,7 @@ impl Program {
2726

2827
#[cfg(windows)]
2928
if path.extension() == Some(OsStr::new("lnk")) {
30-
if let Ok(target) = utils::resolve_shortcut_target(&path) {
29+
if let Ok(target) = kal_utils::resolve_shortcut_target(&path) {
3130
description = get_app_type(&target).description().into();
3231
}
3332
}
@@ -43,15 +42,17 @@ impl Program {
4342
fn item(&self, args: &str, score: u16) -> ResultItem {
4443
let path = self.path.clone();
4544
let args_ = args.to_string();
46-
let open = Action::primary(move |_| utils::execute_with_args(&path, &args_, false, false));
45+
let open =
46+
Action::primary(move |_| kal_utils::execute_with_args(&path, &args_, false, false));
4747

4848
let path = self.path.clone();
4949
let args_ = args.to_string();
50-
let open_elevated =
51-
Action::open_elevated(move |_| utils::execute_with_args(&path, &args_, true, false));
50+
let open_elevated = Action::open_elevated(move |_| {
51+
kal_utils::execute_with_args(&path, &args_, true, false)
52+
});
5253

5354
let path = self.path.clone();
54-
let open_location = Action::open_location(move |_| utils::reveal_item_in_dir(&path));
55+
let open_location = Action::open_location(move |_| kal_utils::reveal_item_in_dir(&path));
5556

5657
let tooltip = format!("{}\n{}", self.name.to_string_lossy(), self.path.display());
5758

kal-plugins/calculator/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "kal-plugin-calculator"
3+
version = "0.2.0"
4+
description = "Calculator plugin for kal."
5+
authors = ["Amr Bashir <[email protected]>"]
6+
repository = "https://github.com/amrbashir/kal"
7+
license = "MIT"
8+
edition = "2021"
9+
10+
[dependencies]
11+
kal-config = { path = "../../kal-config" }
12+
kal-plugin = { path = "../../kal-plugin" }
13+
anyhow.workspace = true
14+
async-trait.workspace = true
15+
sci-calc = "1.0.1"
16+
arboard = "3.4"

kal/src/plugins/calculator/mod.rs renamed to kal-plugins/calculator/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use kal_config::Config;
2-
use kal_plugin::{Action, PluginQueryOutput, ResultItem};
3-
4-
use crate::icon::BuiltinIcon;
2+
use kal_plugin::{Action, BuiltinIcon, PluginQueryOutput, ResultItem};
53

64
#[derive(Debug)]
75
pub struct Plugin;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "kal-plugin-directory-indexer"
3+
version = "0.2.0"
4+
description = "Directory indexer plugin for kal."
5+
authors = ["Amr Bashir <[email protected]>"]
6+
repository = "https://github.com/amrbashir/kal"
7+
license = "MIT"
8+
edition = "2021"
9+
10+
[dependencies]
11+
kal-config = { path = "../../kal-config" }
12+
kal-plugin = { path = "../../kal-plugin" }
13+
kal-utils = { path = "../../kal-utils" }
14+
anyhow.workspace = true
15+
async-trait.workspace = true
16+
smol.workspace = true
17+
serde.workspace = true
18+
19+
[target.'cfg(target_os = "windows")'.dependencies.windows]
20+
workspace = true
21+
features = ["Win32_Storage_FileSystem"]

0 commit comments

Comments
 (0)