Add readme and dist setup

This commit is contained in:
Peder Bergebakken Sundt 2018-03-04 18:23:45 +01:00
parent 86c830b655
commit 1c7116fd75
7 changed files with 85 additions and 1 deletions

45
README.md Normal file
View File

@ -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
```

5
config.py Normal file
View File

@ -0,0 +1,5 @@
# network interface ip
address = "0.0.0.0"
# http listen port
port = 8080

14
dist/grzegorz@.service vendored Normal file
View File

@ -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

8
dist/xorg@.service vendored Normal file
View File

@ -0,0 +1,8 @@
[Unit]
Description=Socket for xorg at display %i
[Socket]
ListenStream=/tmp/.X11-unix/X%i
[Install]
WantedBy=sockets.target

8
dist/xorg@.socket vendored Normal file
View File

@ -0,0 +1,8 @@
[Unit]
Description=Socket for xorg at display %i
[Socket]
ListenStream=/tmp/.X11-unix/X%i
[Install]
WantedBy=sockets.target

View File

@ -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()

BIN
res/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB