232 lines
5.2 KiB
Markdown
232 lines
5.2 KiB
Markdown
# GNOME Notification Forwarder
|
|
|
|
Forward all GNOME desktop notifications to Bark or Gotify.
|
|
|
|
## Features
|
|
|
|
- Monitors all GNOME desktop notifications in real-time
|
|
- Forwards notifications to Bark API or Gotify automatically
|
|
- Support for multiple notification services (Bark, Gotify, or both)
|
|
- Includes application name in forwarded messages
|
|
- Runs as a systemd service for automatic startup
|
|
- Comprehensive logging
|
|
|
|
## Prerequisites
|
|
|
|
- Linux with GNOME desktop environment
|
|
- Python 3.6+
|
|
- D-Bus (pre-installed on most GNOME systems)
|
|
|
|
## Installation
|
|
|
|
### 1. Install Python dependencies
|
|
|
|
```bash
|
|
# Install system dependencies
|
|
sudo pacman -S python-dbus python-gobject python-requests
|
|
|
|
# OR using pip (if not using Arch)
|
|
pip3 install -r requirements.txt
|
|
```
|
|
|
|
### 2. Make the script executable
|
|
|
|
```bash
|
|
chmod +x notify_forwarder.py
|
|
```
|
|
|
|
### 3. Test the script
|
|
|
|
```bash
|
|
./notify_forwarder.py
|
|
```
|
|
|
|
Then send a test notification:
|
|
```bash
|
|
notify-send "Test Title" "Test message body"
|
|
```
|
|
|
|
You should see the notification forwarded to your Bark app and logged in the terminal.
|
|
|
|
## Running as a Service
|
|
|
|
### Set up systemd user service
|
|
|
|
1. Create the systemd user directory if it doesn't exist:
|
|
```bash
|
|
mkdir -p ~/.config/systemd/user
|
|
```
|
|
|
|
2. Copy the service file:
|
|
```bash
|
|
cp notify-forwarder.service ~/.config/systemd/user/
|
|
```
|
|
|
|
3. Reload systemd:
|
|
```bash
|
|
systemctl --user daemon-reload
|
|
```
|
|
|
|
4. Enable and start the service:
|
|
```bash
|
|
systemctl --user enable notify-forwarder.service
|
|
systemctl --user start notify-forwarder.service
|
|
```
|
|
|
|
5. Check the service status:
|
|
```bash
|
|
systemctl --user status notify-forwarder.service
|
|
```
|
|
|
|
6. View logs:
|
|
```bash
|
|
journalctl --user -u notify-forwarder.service -f
|
|
```
|
|
|
|
## Configuration
|
|
|
|
Configuration is done via environment variables in your `~/.zshrc` file.
|
|
|
|
### Choose Notification Service
|
|
|
|
Set the `NOTIFICATION_SERVICE` variable to control which service(s) to use:
|
|
|
|
```bash
|
|
# Options: bark, gotify, or both (default: bark)
|
|
export NOTIFICATION_SERVICE="bark"
|
|
```
|
|
|
|
### Configure Bark
|
|
|
|
If using Bark (default), add the following to your `~/.zshrc`:
|
|
|
|
```bash
|
|
export BARK_URL="https://api.day.app/YOUR_BARK_KEY"
|
|
```
|
|
|
|
### Configure Gotify
|
|
|
|
If using Gotify, add the following to your `~/.zshrc`:
|
|
|
|
```bash
|
|
export GOTIFY_URL="https://gotify.example.com"
|
|
export GOTIFY_TOKEN="your_gotify_app_token"
|
|
```
|
|
|
|
### Use Both Services
|
|
|
|
To forward notifications to both Bark and Gotify simultaneously:
|
|
|
|
```bash
|
|
export NOTIFICATION_SERVICE="both"
|
|
export BARK_URL="https://api.day.app/YOUR_BARK_KEY"
|
|
export GOTIFY_URL="https://gotify.example.com"
|
|
export GOTIFY_TOKEN="your_gotify_app_token"
|
|
```
|
|
|
|
### Apply Configuration
|
|
|
|
After editing `~/.zshrc`, reload it:
|
|
|
|
```bash
|
|
source ~/.zshrc
|
|
```
|
|
|
|
Then restart the service if it's already running:
|
|
|
|
```bash
|
|
systemctl --user restart notify-forwarder.service
|
|
```
|
|
|
|
## Stopping the Service
|
|
|
|
```bash
|
|
# Stop the service
|
|
systemctl --user stop notify-forwarder.service
|
|
|
|
# Disable auto-start
|
|
systemctl --user disable notify-forwarder.service
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### No notifications being forwarded
|
|
|
|
1. Check if the service is running:
|
|
```bash
|
|
systemctl --user status notify-forwarder.service
|
|
```
|
|
|
|
2. Check the logs:
|
|
```bash
|
|
journalctl --user -u notify-forwarder.service -n 50
|
|
```
|
|
|
|
3. Test your notification service manually:
|
|
|
|
For Bark:
|
|
```bash
|
|
curl "https://api.day.app/YOUR_BARK_KEY/Test/Message"
|
|
```
|
|
|
|
For Gotify:
|
|
```bash
|
|
curl -X POST "https://gotify.example.com/message?token=YOUR_TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"title":"Test","message":"Test message","priority":5}'
|
|
```
|
|
|
|
### Permission issues
|
|
|
|
Make sure the script has execute permissions:
|
|
```bash
|
|
chmod +x notify_forwarder.py
|
|
```
|
|
|
|
### D-Bus connection issues
|
|
|
|
Ensure you're running the service as a user service (not system service), as it needs access to your user's D-Bus session.
|
|
|
|
## Uninstallation
|
|
|
|
```bash
|
|
# Stop and disable the service
|
|
systemctl --user stop notify-forwarder.service
|
|
systemctl --user disable notify-forwarder.service
|
|
|
|
# Remove the service file
|
|
rm ~/.config/systemd/user/notify-forwarder.service
|
|
|
|
# Reload systemd
|
|
systemctl --user daemon-reload
|
|
|
|
# Remove the project directory
|
|
rm -rf /home/lostecho/Documents/notify-forwarder
|
|
```
|
|
|
|
## License
|
|
|
|
MIT License
|
|
|
|
Copyright (c) 2025 lostecho
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
|
|
See the [LICENSE](LICENSE) file for details.
|