aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: c7f0f8a9e6618fa3f2a53cdb8db9569e5228e13d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
qm plugin protocol with example. A "file manager" plugin example is written in shell script, python and zig

# Protocol
## Input
Plugins get inputs as environment variables.\
The environment variable `ACTION` is set to `get` to get data.\
The environment variable `URL` is set to _url_ relevant to the page, so for example for a file manager `URL` is set to the directory to display files of.
## Output
Plugins output data by writing lines to stdout.\
Data is first written to stdout and then a _command_ is written to stdout.\
First `add_tab` command is expected, followed by multiple `add_body_item`. The body items are put in the tab that is output before the body items.\
In plugins you may need to output newlines (\n) or carriage return (\r), in those cases replace newline with ascii 1 (\x01) and carriage return with ascii 2 (\x02).\
Text color/font bold, etc can be set by using ANSI escape codes, see [ANSI escape code wikipedia](https://en.wikipedia.org/wiki/ANSI_escape_code) and this [practical example](https://gist.github.com/JBlond/2fea43a3049b38287e5e9cefc87b2124).
### add_tab
The add_tab command expects `title` data, for example:
```bash
echo "title Files"
echo "add_tab"
```
### add_body_item
The add_body_item command expects `title` and `url` data and optionally `thumbnail_url` and `thumbnail_size`, for example:
```bash
echo "title file.png"
echo "url img1.png"
echo "thumbnail_url img1.png"
echo "thumbnail_size 1920x1080"
echo "add_body_item"

echo "title img2.png"
echo "url img2.png"
echo "thumbnail_url img2.png"
echo "thumbnail_size 1280x720"
echo "add_body_item"
```