mirror of
https://github.com/simbelmas/gotify-dunst.git
synced 2026-01-26 14:46:28 +01:00
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
13
Makefile
Normal file
13
Makefile
Normal 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/
|
||||||
36
README.md
36
README.md
@@ -1,6 +1,7 @@
|
|||||||
<h1 align="center">gotify-dunst</h1>
|
<h1 align="center">gotify-dunst</h1>
|
||||||
|
|
||||||
## Intro
|
## 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/).
|
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
|
## Features
|
||||||
@@ -12,14 +13,27 @@ This is a simple script for receiving [Gotify](https://github.com/gotify/server)
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
1. Clone this repo
|
### Debian (Ubuntu, Mint, etc.)
|
||||||
<code>git clone https://github.com/ztpnk/gotify-dunst && cd gotify-dunst</code>
|
|
||||||
2. Create a python venv `python3 -m venv .env`
|
```bash
|
||||||
3. Install python requirements
|
sudo apt install git make libnotify-bin python3-websocket
|
||||||
<code>./.env/bin/pip install -r requirements.txt</code>
|
git clone https://github.com/ztpnk/gotify-dunst
|
||||||
4. Change the domain and token in main.py
|
cd gotify-dunst
|
||||||
5. Test if it runs
|
sudo make install
|
||||||
<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
|
### Arch (Manjaro)
|
||||||
<code>sudo systemd start gotify-dunst && sudo systemd enable gotify-dunst</code>
|
|
||||||
|
```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
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