2025-11-07 16:29:50 +08:00
2025-11-07 16:29:50 +08:00
2025-11-07 16:29:50 +08:00
2025-11-07 16:24:30 +08:00
2025-11-07 16:29:50 +08:00
2025-11-07 16:29:50 +08:00
2025-11-07 16:29:50 +08:00
2025-11-07 16:29:50 +08:00

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

# 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

chmod +x notify_forwarder.py

3. Test the script

./notify_forwarder.py

Then send a test notification:

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:
mkdir -p ~/.config/systemd/user
  1. Copy the service file:
cp notify-forwarder.service ~/.config/systemd/user/
  1. Reload systemd:
systemctl --user daemon-reload
  1. Enable and start the service:
systemctl --user enable notify-forwarder.service
systemctl --user start notify-forwarder.service
  1. Check the service status:
systemctl --user status notify-forwarder.service
  1. View logs:
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:

# Options: bark, gotify, or both (default: bark)
export NOTIFICATION_SERVICE="bark"

Configure Bark

If using Bark (default), add the following to your ~/.zshrc:

export BARK_URL="https://api.day.app/YOUR_BARK_KEY"

Configure Gotify

If using Gotify, add the following to your ~/.zshrc:

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:

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:

source ~/.zshrc

Then restart the service if it's already running:

systemctl --user restart notify-forwarder.service

Stopping the Service

# 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:
systemctl --user status notify-forwarder.service
  1. Check the logs:
journalctl --user -u notify-forwarder.service -n 50
  1. Test your notification service manually:

For Bark:

curl "https://api.day.app/YOUR_BARK_KEY/Test/Message"

For Gotify:

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:

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

# 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 file for details.

Description
No description provided
Readme MIT 35 KiB
Languages
Python 91.2%
Shell 8.8%