-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,65 @@ | ||
## Sending API requests to FLow Launcher | ||
# Sending API requests to FLow Launcher | ||
|
||
You can send special requests to Flow Launcher to control the launcher from your plugin. This communication is currently only one way. | ||
|
||
!!! warning | ||
|
||
You can not send API requests from a query or context_menu method! | ||
You can not send API requests from a query or context_menu method! | ||
|
||
Using API requests in this way will cause your plugin to fail! | ||
|
||
### Sending a command from a Result | ||
## Sending a command from a Result | ||
|
||
``` | ||
from pyflowlauncher import Plugin, Result, send_results, api | ||
from pyflowlauncher.result import JsonRPCAction, ResultResponse | ||
```py | ||
from pyflowlauncher import Plugin, Result, send_results, api | ||
from pyflowlauncher.result import JsonRPCAction, ResultResponse | ||
|
||
plugin = Plugin() | ||
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", | ||
JsonRPCAction=api.change_query("This is a new query!"), | ||
) | ||
return send_results([r]) | ||
@plugin.on_method | ||
def query(query: str) -> ResultResponse: | ||
r = Result( | ||
Title="This is a title!", | ||
SubTitle="This is the subtitle!", | ||
IcoPath="icon.png", | ||
JsonRPCAction=api.change_query("This is a new query!"), | ||
) | ||
return send_results([r]) | ||
|
||
|
||
plugin.run() | ||
``` | ||
plugin.run() | ||
``` | ||
|
||
The example above will change the query in Flow Launcher when the user selects your result. | ||
|
||
|
||
### Sending a command from a Method | ||
## Sending a command from a Method | ||
|
||
You can also send an API request in a custom method like so: | ||
|
||
``` | ||
from pyflowlauncher import Plugin, Result, send_results, api | ||
from pyflowlauncher.result import JsonRPCAction, ResultResponse | ||
```py | ||
from pyflowlauncher import Plugin, Result, send_results, api | ||
from pyflowlauncher.result import JsonRPCAction, ResultResponse | ||
|
||
plugin = Plugin() | ||
plugin = Plugin() | ||
|
||
|
||
@plugin._on_method | ||
def example_method() -> JsonRPCAction: | ||
# Do stuff here | ||
return api.change_query("This is also a new query!") | ||
@plugin._on_method | ||
def example_method() -> JsonRPCAction: | ||
# Do stuff here | ||
return api.change_query("This is also a new query!") | ||
|
||
|
||
@plugin.on_method | ||
def query(query: str) -> ResultResponse: | ||
r = Result( | ||
Title="This is a title!", | ||
SubTitle="This is the subtitle!", | ||
IcoPath="icon.png", | ||
) | ||
r.add_action(example_method) | ||
return send_results([r]) | ||
@plugin.on_method | ||
def query(query: str) -> ResultResponse: | ||
r = Result( | ||
Title="This is a title!", | ||
SubTitle="This is the subtitle!", | ||
IcoPath="icon.png", | ||
) | ||
r.add_action(example_method) | ||
return send_results([r]) | ||
|
||
|
||
plugin.run() | ||
``` | ||
plugin.run() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Home | ||
|
||
{!README.md!} | ||
{!README.md!} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## API Reference | ||
# API Reference | ||
|
||
::: pyflowlauncher.api | ||
::: pyflowlauncher.api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# event | ||
|
||
::: pyflowlauncher.event | ||
handler: python | ||
options: | ||
separate_signature: true | ||
show_signature_annotations: true | ||
|
||
handler: python | ||
options: | ||
separate_signature: true | ||
show_signature_annotations: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
## Plugin Reference | ||
# Plugin Reference | ||
|
||
::: pyflowlauncher.plugin.Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
::: pyflowlauncher.result | ||
# result | ||
|
||
::: pyflowlauncher.result |