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. Please note that some features might have varying levels of support across different Linux distributions.

Features:

  • Send notifications with custom titles, messages, and images
  • Include clickable buttons for user interaction
  • Control notification urgency, timeout, and sound
  • Replace an active notification using its ID.
  • Close a specific notification by its ID.
  • Clear all notifications sent by the application.
  • Receive callbacks when a notification is closed by the user, client, or timeout. 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

This library offers two primary usage approaches:

Command-Line Interaction

If you prefer a quick way to view information or control playback, you can potentially execute the dbus-notification script directly, though this doesn't support button actions. For more extensive programmatic control, I would recommend using the library within your Python code.

Programmatic Control

Import the DBusNotification class from your Python code:

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
)
time.sleep(3)

notification_id = dbus_app.send(
    title="Updated Message",
    message="This is the new message body.",
    notifyid=notification_id,
)
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_all()

# Keep the app running
while True:
    time.sleep(1)

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.2.0.tar.gz (5.5 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.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dbus_notification-2026.2.0.tar.gz
  • Upload date:
  • Size: 5.5 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.2.0.tar.gz
Algorithm Hash digest
SHA256 e8cbd815644a7fb9538bbbf36508649d3e62020c52159cb31263121dfbda8d6a
MD5 c3a020e6d1aa1e0c7ed73fe420179da0
BLAKE2b-256 4c0b275effcef186e7b70c2a2ff81c70407f77e2ed56be39ed75fd8ead951c37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dbus_notification-2026.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 89a2f8abed577ba1343791bdb95c7fcf639bbb1bd2b39cdc7a6e9b08625456fb
MD5 29554849d77154d1355601890f06a9fd
BLAKE2b-256 c4ecdde63ccb8b9e17ed356755583d8d12eb50ac6c060e534e64eafd43842d5d

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