Öncelikle yüklü değilse Dbus modülünü kurmalısın.
pip3 install dbus-pythonÇalışma prensibi şu şekilde.
import dbus
item = "org.freedesktop.Notifications"
notfy_intf = dbus.Interface(
dbus.SessionBus().get_object(item, "/"+item.replace(".", "/")), item)
notfy_intf.Notify(
"", 0, "", "Hello world!", "This is the notification body.",
[], {"urgency": 1}, 3000)
Elementary OS üzerinde çalıştı. Çoğu dağıtımda çalışıyordur.
import subprocess
subprocess.run(
["notify-send", "-u", "normal", "-t", "3000",
"Hello world", "This is the notification body."],
check=True)
Bu da çalışıyor hangisini tercih edersen.
Kaynak:
Sending desktop notification in Linux with Python with D-Bus directly | import pyChao