Add readme and dist setup
This commit is contained in:
parent
86c830b655
commit
1c7116fd75
|
@ -0,0 +1,45 @@
|
||||||
|
# Grzegorz API
|
||||||
|
<img align="right" width="250" src="res/logo.png">
|
||||||
|
|
||||||
|
Grzegorz is simple REST API for managing an instance of MPV.
|
||||||
|
|
||||||
|
Why the name Grzegorz? [We have a bad tast in humor!](https://youtu.be/t-fcrn1Edik)
|
||||||
|
|
||||||
|
When Grzegorz starts, it launches an instance of MPV and maintains it. It is designed to be used as an infoscreen or HTPC, and supports multiple users to push changes to the MPV instance.
|
||||||
|
|
||||||
|
The API id described and can be tested on `http:/localhost:8080/swagger` when the server is running. All API endpoints are available under `/api`
|
||||||
|
|
||||||
|
|
||||||
|
## How to run it
|
||||||
|
|
||||||
|
First of we need to install any needed dependencies. If you want to, you may do so in a virtual environment.
|
||||||
|
|
||||||
|
To install the needed dependencies, run this with sufficient rights (as root?):
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Gregorz managesa MPV process, meaning you need MPV installed on your system. Look for it in your package manager.
|
||||||
|
|
||||||
|
When finished, you may run the server with:
|
||||||
|
|
||||||
|
```
|
||||||
|
python3 main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
The server should now be available at `http://localhost:8080/`.
|
||||||
|
You may change the address and port in the file named `config.py`
|
||||||
|
|
||||||
|
|
||||||
|
## Making Grzegorz run on boot
|
||||||
|
|
||||||
|
When setting up a infoscreen or HTPC using Grzegors, you may configure it to run automatically on startup.
|
||||||
|
|
||||||
|
We recommend installing a headless linux, and create a user for Grzegorz to run as. (We named ours `grzegorz`, obviously)
|
||||||
|
Then make systemd automatically spin up a X session to run Grzegorz in: Copy the files in the folder `dist` into `$HOME/.config/systemd/user` and run the following commands as your user:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ systemd --user enable grzegorz@0.service
|
||||||
|
$ systemd --user start grzegorz@0.service
|
||||||
|
```
|
|
@ -0,0 +1,5 @@
|
||||||
|
# network interface ip
|
||||||
|
address = "0.0.0.0"
|
||||||
|
|
||||||
|
# http listen port
|
||||||
|
port = 8080
|
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Grzegorz at display %i
|
||||||
|
|
||||||
|
Requires=xorg@%i.socket
|
||||||
|
Requires=xorg@%i.service
|
||||||
|
After=xorg@%i.socket
|
||||||
|
After=xorg@%i.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment="DISPLAY=:%i"
|
||||||
|
ExecStart=/usr/bin/python grzegorz/main.py
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Socket for xorg at display %i
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=/tmp/.X11-unix/X%i
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
|
@ -0,0 +1,8 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Socket for xorg at display %i
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=/tmp/.X11-unix/X%i
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
6
main.py
6
main.py
|
@ -1,11 +1,15 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import asyncio
|
import asyncio
|
||||||
import grzegorz
|
import grzegorz
|
||||||
|
import config
|
||||||
|
|
||||||
async def grzegorz_splash():
|
async def grzegorz_splash():
|
||||||
resp = await grzegorz.mpv_control.loadfile('grzegorz/grzegorz/res/logo.jpg')
|
resp = await grzegorz.mpv_control.loadfile('grzegorz/grzegorz/res/logo.jpg')
|
||||||
#print(resp)
|
#print(resp)
|
||||||
|
|
||||||
loop, app = grzegorz.make_sanic_app()
|
loop, app = grzegorz.make_sanic_app(
|
||||||
|
host = config.address,
|
||||||
|
port = config.port
|
||||||
|
)
|
||||||
asyncio.ensure_future(grzegorz_splash())
|
asyncio.ensure_future(grzegorz_splash())
|
||||||
loop.run_forever()
|
loop.run_forever()
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 157 KiB |
Loading…
Reference in New Issue