feat(spotlight): add plugin system with core engine and examples
- Plugin API (plugin.py, context.py, result.py) - Core engine (search.py, manager.py, registry.py, loader.py) - Built-in plugins: app, calculator, clipboard, emoji, power_menu, query, wallpapers - Spotlight docs and example plugins - Spotlight CSS styling
This commit is contained in:
24 files changed
+3130
-20
No files matched your search
@@ -0,0 +1,46 @@
|
||||
"""Example: simplest possible single-file plugin.
|
||||
|
||||
Usage:
|
||||
cp examples/plugins/hello.py config/plugins/hello.py
|
||||
|
||||
Then open spotlight and type "hi" or "hello".
|
||||
Or deep-reload from terminal:
|
||||
fabric-cli exec modus1 'deep_reload hello'
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from window.spotlight.api import SearchResult, SpotlightPlugin
|
||||
|
||||
|
||||
class HelloPlugin(SpotlightPlugin):
|
||||
id = "hello"
|
||||
name = "Hello"
|
||||
icon = "face-smile-symbolic"
|
||||
keywords = ["hi", "hello"]
|
||||
searchable = True
|
||||
priority = 100
|
||||
|
||||
def initialize(self) -> None:
|
||||
pass
|
||||
|
||||
def cleanup(self) -> None:
|
||||
pass
|
||||
|
||||
def search(self, query: str, token: Any) -> list[SearchResult]:
|
||||
if not query.strip():
|
||||
return []
|
||||
return [
|
||||
SearchResult(
|
||||
id="hello_world",
|
||||
title="Hello, World!",
|
||||
subtitle="A friendly greeting",
|
||||
icon_name="face-smile-symbolic",
|
||||
score=100.0,
|
||||
render_type="default",
|
||||
action=lambda: print("Hello!"),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
PLUGIN = HelloPlugin
|
||||
Reference in new issue
Block a user