Skip to main content

Sends notifications using DBus

Project description

DBus Notification

PyPI Python versions License

This library provides a simple interface for creating and displaying desktop notifications with custom buttons using DBus.

Features:

  • Send notifications with custom titles, messages, and images
  • Interactive Buttons: Include clickable buttons that trigger callbacks
  • Urgency & Sounds: Control urgency levels (0, 1, or 2) and trigger system sounds or file-based alerts
  • Management: Replace, close, or clear all notifications sent by the application
  • Unique Tracking: Use uniqueid to update specific notifications without managing raw notification IDs Note: Some features might have limited support depending on your desktop environment.

Requirements

DBus Notification has minimal system dependencies:

  • Python 3.7 or later
  • jeepney library

Installation

Install the library using pip:

pip install dbus-notification

Usage

Command-Line Interaction

You can send quick notifications directly from your terminal using the following flags:

Flag Description
-t, --title The bold heading of the notification.
-m, --message The body text of the notification.
-l, --logo Path to a small icon/logo.
-i, --image Path to a large image preview.
-s, --sound System sound name (e.g., message-new-instant) or full file path.
-u, --urgency 0 (Low), 1 (Normal), or 2 (Critical).
-c, --timeout Milliseconds until the notification expires (-1 for default).

Example:

dbus-notification -t "Hello" -m "This is a test" -u 1

Programmatic Control

The DBusNotification class allows for advanced interaction and button callbacks.

import time
from dbus_notification import DBusNotification

def callback(notification_type, notification):
    if notification_type == "closed":
        print(f"Notification {notification['id']} has closed.")
    elif notification_type == "button":
        print(f"Notification {notification['id']} has clicked on the button {notification['button']}.")

dbus_app = DBusNotification(appname="dbus_notification", callback=callback)

notification_id = dbus_app.send(
    title="Initial Message",
    message="This message will be replaced in 3 seconds.",
    logo="logo.png",
    image="myimage.png",
    sound="message-new-instant",
    actions=["Test Button"],
    urgency=1,
    timeout=5000, # 5 seconds
    uniqueid="test_notification",
)
time.sleep(3)

notification_id = dbus_app.send(
    title="Updated Message",
    message="This is the new message body.",
    uniqueid="test_notification",
)
time.sleep(3)
dbus_app.close(notification_id)

dbus_app.send(title="N2", message="A second notification.")
dbus_app.send(title="N3", message="A third notification.")
time.sleep(3)

dbus_app.close()

To run a long-running callback monitor from a source checkout:

python examples/callback_monitor.py

To create 10 notifications with unique IDs and close them one by one:

python examples/close_unique_notifications.py

Future Features

  • Support for notification categories
  • Resident or transient notification options
  • Ability to specify notification position on the screen

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbus_notification-2026.6.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbus_notification-2026.6.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file dbus_notification-2026.6.0.tar.gz.

File metadata

  • Download URL: dbus_notification-2026.6.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for dbus_notification-2026.6.0.tar.gz
Algorithm Hash digest
SHA256 f77a8850bb5770f8a5cab70a9a18bcbf672ab6dc9d26f1e162ac4194bd655704
MD5 686bdde0d82cbe37d0a2f964e8cfa033
BLAKE2b-256 68ad12927b6942d74d4d6e823ecdbaca2ed030a456c498d82aa235d39201f817

See more details on using hashes here.

File details

Details for the file dbus_notification-2026.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dbus_notification-2026.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db7a1da2ed3d4aa97b4ae3b90e99144755702ab41ae2a12847bd015eb88cd0c6
MD5 dce592d45af77a7f13b8b998d6944092
BLAKE2b-256 50e6a162e8cc8b579a7cbb251ce047eef94a25f2228a8e0c3c61b3e6c7c87452

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page