From c2308daf897055e056a0a51fbc445f7902c2f90b Mon Sep 17 00:00:00 2001 From: Kevin Date: Sat, 14 Sep 2024 04:15:27 -0300 Subject: Added examples for python and lua --- docs/libraries/notifd.md | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'docs/libraries/notifd.md') diff --git a/docs/libraries/notifd.md b/docs/libraries/notifd.md index 2ba0b7b..eb074cd 100644 --- a/docs/libraries/notifd.md +++ b/docs/libraries/notifd.md @@ -68,20 +68,41 @@ astal-notifd --help ```js [ JavaScript] import Notifd from "gi://AstalNotifd"; -const notifd = Notifd.get_default() +const notifd = Notifd.get_default(); notifd.connect("notified", (_, id) => { - const n = notifd.get_notification(id) - console.log(n.summary, n.body) -}) + const n = notifd.get_notification(id); + console.log(n.summary, n.body); +}); ``` ```py [ Python] -# Not yet documented +import gi + +gi.require_version("AstalNotifd", "0.1") + +from gi.repository import AstalNotifd + +notifd = AstalNotifd.get_default() + +def on_notified(_, id): + n = notifd.get_notification(id) + print(n.get_body(), n.get_body()) + +notifd.connect("notified", on_notified) ``` ```lua [ Lua] --- Not yet documented +local lgi = require("lgi") + +local AstalNotifd = lgi.require("AstalNotifd", "0.1") + +local notifd = AstalNotifd.get_default() + +notifd.on_notified = function(_, id) + local n = notifd.get_notification(id) + print(n.body, n.summary) +end ``` ```vala [ Vala] -- cgit v1.2.3