A Tauri plugin that provides a MacOS Spotlight-like search functionality for Tauri windows.
Spotlight is a Tauri plugin that provides a user-friendly and intuitive way to interact with your desktop applications - the Spotlight search-like interface.
This plugin is currently implemented for macOS, but has basic implementations for other platforms.
Features:
Install the Core plugin by adding the following to your Cargo.toml file:
src-tauri/Cargo.toml
toml
[dependencies]
tauri-plugin-spotlight = { git = "https://github.com/zzzze/tauri-plugin-spotlight" }
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
```bash pnpm add tauri-plugin-spotlight-api
npm add tauri-plugin-spotlight-api
yarn add tauri-plugin-spotlight-api ```
There are three ways to configure the plugin:
src-tauri/src/main.rs
rust
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_spotlight::init(Some(tauri_plugin_spotlight::PluginConfig {
windows: Some(vec![
tauri_plugin_spotlight::WindowConfig {
label: String::from("main"),
shortcut: String::from("Ctrl+Shift+J"),
},
]),
close_shortcut: Some(String::from("Escape")),
hide_when_inactive: Some(true),
})))
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
src-tauri/tauri.conf.json
json
{
"plugins": {
"spotlight": {
"windows": [{
"label": "main",
"shortcut": "Ctrl+Shift+J"
}],
"close_shortcut": "Escape",
"hide_when_inactive": true
}
}
}
src-tauri/src/main.rs
rust
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_spotlight::init(None))
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
src-tauri/src/main.rs
```rust use tauripluginspotlight::ManagerExt;
fn main() { tauri::Builder::default() .plugin(tauripluginspotlight::init(Some(tauripluginspotlight::PluginConfig { windows: None, closeshortcut: Some(String::from("Escape")), hidewheninactive: Some(true), }))) .setup(|mut app| { if let Some(window) = app.getwindow("main") { app.spotlight().initspotlightwindow(&window, "Ctrl+Shift+J").unwrap(); } appmodifier::apply(&mut app); Ok(()) }) .build(tauri::generatecontext!()) .expect("error while running application"); } ```
The configuration parameters written in tauri.conf.json
and tauri_plugin_spotlight::init
will be automatically merged with tauri_plugin_spotlight::init
taking higher priority.
Use the hide
function to make a spotlight window invisible:
```typescript import { hide } from 'tauri-plugin-spotlight-api';
void hide(); ```
This plugin was inspired by the tauri-macos-spotlight-example project by ahkohd, and borrows heavily from its codebase. Thanks to ahkohd and the contributors to tauri-macos-spotlight-example for their hard work and open-source contributions!