Merge pull request #3 from karmanyaahm/master

Changes during packaging
This commit is contained in:
Karmanyaah Malhotra
2020-11-08 00:55:11 -05:00
committed by GitHub
6 changed files with 67 additions and 17 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env

13
Makefile Normal file
View File

@@ -0,0 +1,13 @@
ifeq ($(PREFIX),)
PREFIX := /usr
endif
install:
# systemd file
install -d $(DESTDIR)$(PREFIX)/lib/systemd/user/
install gotify-dunst.service $(DESTDIR)$(PREFIX)/lib/systemd/user/
# files in /usr/lib
install -d $(DESTDIR)$(PREFIX)/lib/gotify-dunst/
install main.py $(DESTDIR)$(PREFIX)/lib/gotify-dunst/
install gotify-dunst.conf $(DESTDIR)$(PREFIX)/lib/gotify-dunst/

View File

@@ -1,6 +1,7 @@
<h1 align="center">gotify-dunst</h1>
## Intro
This is a simple script for receiving [Gotify](https://github.com/gotify/server) messages on a Linux Desktop via [dunst](https://dunst-project.org/).
## Features
@@ -12,14 +13,27 @@ This is a simple script for receiving [Gotify](https://github.com/gotify/server)
## Installation
1. Clone this repo
<code>git clone https://github.com/ztpnk/gotify-dunst && cd gotify-dunst</code>
2. Create a python venv `python3 -m venv .env`
3. Install python requirements
<code>./.env/bin/pip install -r requirements.txt</code>
4. Change the domain and token in main.py
5. Test if it runs
<code>./.env/bin/python main.py</code>
6. Customize the gotify-dunst.service and copy it to /etc/systemd/system
7. Start and enable the Systemd Unit
<code>sudo systemd start gotify-dunst && sudo systemd enable gotify-dunst</code>
### Debian (Ubuntu, Mint, etc.)
```bash
sudo apt install git make libnotify-bin python3-websocket
git clone https://github.com/ztpnk/gotify-dunst
cd gotify-dunst
sudo make install
```
### Arch (Manjaro)
```bash
sudo pacman -Syu make git libnotify python-websocket-client
git clone https://github.com/ztpnk/gotify-dunst
cd gotify-dunst
sudo make install
```
## Usage
1. Run `systemctl --user enable --now gotify-dunst.service` (**no sudo**)
2. Open `~/.config/gotify-dunst/gotify-dunst.conf` in your favorite text editor. Modify the domain to your instance of Gotify and modify the token to a client token you get from the Gotify web app.
3. Run `systemctl --user restart gotify-dunst.service`.
4. (optionally) You can check the status of the service with `systemctl --user status gotify-dunst.service`.

3
gotify-dunst.conf Normal file
View File

@@ -0,0 +1,3 @@
[server]
domain=push.example.com
token=C2Un.92TZBzsukg

View File

@@ -3,10 +3,9 @@ Description=Gotify-Dunst
After=network.target
[Service]
User=<user>
WorkingDirectory=<your-path>/gotify-dunst/
ExecStart=<your-path>/gotify-dunst/.env/bin/python main.py
WorkingDirectory=/usr/lib/gotify-dunst/
ExecStart=/usr/bin/env python3 main.py
Restart=always
[Install]
WantedBy=multi-user.target
WantedBy=default.target

24
main.py
View File

@@ -3,11 +3,31 @@ from urllib.request import urlopen
import json
import subprocess
import os.path
import configparser
domain = "push.example.com"
token = "z2Uny92TZBzsukg"
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)
if not os.path.isdir(path):
os.mkdir(path)