Garulf / pyFlowLauncher

Python JSON-RPC library for Flow Launcher plugins.
https://garulf.github.io/pyFlowLauncher/
MIT License
11 stars 1 forks source link
flow-launcher flow-launcher-plugins

Tests Workflow Status Docs Workflow Status Release Workflow Status pypi PyPI - Python Version GitHub License buymeacoffee

pyFlowLauncher

pyFlowLauncher is an API that allows you to quickly create plugins for Flow Launcher!

Installation

Install via pip:

python -m pip install pyflowlauncher[all]

[!IMPORTANT] Please use the [all] flag in order to support Python versions older then 3.11.

Usage

Basic plugin

A basic plugin using a function as the query method.

from pyflowlauncher import Plugin, Result, send_results
from pyflowlauncher.result import ResultResponse

plugin = Plugin()

@plugin.on_method
def query(query: str) -> ResultResponse:
    r = Result(
        Title="This is a title!",
        SubTitle="This is the subtitle!",
        IcoPath="icon.png"
    )
    return send_results([r])

plugin.run()

Advanced plugin

A more advanced usage using a Method class as the query method.

from pyflowlauncher import Plugin, Result, Method
from pyflowlauncher.result import ResultResponse

plugin = Plugin()

class Query(Method):

    def __call__(self, query: str) -> ResultResponse:
        r = Result(
            Title="This is a title!",
            SubTitle="This is the subtitle!"
        )
        self.add_result(r)
        return self.return_results()

plugin.add_method(Query())
plugin.run()