mirror of
https://github.com/simbelmas/gotify-dunst.git
synced 2026-01-19 14:35:23 +01:00
config file
Improve config management. Modify service file to support install Fix config directory creation
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
3
gotify-dunst.conf
Normal file
3
gotify-dunst.conf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[server]
|
||||||
|
domain=push.example.com
|
||||||
|
token=C2Un.92TZBzsukg
|
||||||
@@ -3,10 +3,9 @@ Description=Gotify-Dunst
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=<user>
|
WorkingDirectory=/usr/lib/gotify-dunst/
|
||||||
WorkingDirectory=<your-path>/gotify-dunst/
|
ExecStart=/usr/bin/env python3 main.py
|
||||||
ExecStart=<your-path>/gotify-dunst/.env/bin/python main.py
|
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=default.target
|
||||||
|
|||||||
24
main.py
24
main.py
@@ -3,11 +3,31 @@ from urllib.request import urlopen
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import os.path
|
import os.path
|
||||||
|
import configparser
|
||||||
|
|
||||||
|
|
||||||
domain = "push.example.com"
|
|
||||||
token = "z2Uny92TZBzsukg"
|
|
||||||
|
|
||||||
home = os.path.expanduser('~')
|
home = os.path.expanduser('~')
|
||||||
|
configpath = home+'/.config/gotify-dunst/gotify-dunst.conf'
|
||||||
|
|
||||||
|
if not os.path.isfile(configpath):
|
||||||
|
from shutil import copyfile
|
||||||
|
from os import makedirs
|
||||||
|
makedirs(home+'/.config/gotify-dunst/',exist_ok=True)
|
||||||
|
copyfile('gotify-dunst.conf',configpath)
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(configpath)
|
||||||
|
|
||||||
|
domain = config.get('server','domain',fallback=None)
|
||||||
|
|
||||||
|
if domain in [ "push.example.com", None]:
|
||||||
|
print("Confiuration error. Make sure you have properly modified the configuration")
|
||||||
|
exit()
|
||||||
|
|
||||||
|
token = config.get('server','token')
|
||||||
|
|
||||||
|
|
||||||
path = "{}/.cache/gotify-dunst".format(home)
|
path = "{}/.cache/gotify-dunst".format(home)
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user