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 From 4d5c7a7b514c7f4f71b2950f051b64c3e3df3008 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sat, 14 Sep 2024 09:55:29 +0000 Subject: docs: lib examples consistency --- docs/libraries/notifd.md | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'docs/libraries/notifd.md') diff --git a/docs/libraries/notifd.md b/docs/libraries/notifd.md index eb074cd..7e02149 100644 --- a/docs/libraries/notifd.md +++ b/docs/libraries/notifd.md @@ -66,24 +66,20 @@ astal-notifd --help :::code-group ```js [ JavaScript] -import Notifd from "gi://AstalNotifd"; +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) + print(n.summary, n.body) +}) ``` ```py [ Python] -import gi +from gi.repository import AstalNotifd as Notifd -gi.require_version("AstalNotifd", "0.1") - -from gi.repository import AstalNotifd - -notifd = AstalNotifd.get_default() +notifd = Notifd.get_default() def on_notified(_, id): n = notifd.get_notification(id) @@ -93,15 +89,13 @@ notifd.connect("notified", on_notified) ``` ```lua [ Lua] -local lgi = require("lgi") - -local AstalNotifd = lgi.require("AstalNotifd", "0.1") +local Notifd = require("lgi").require("AstalNotifd") -local notifd = AstalNotifd.get_default() +local notifd = Notifd.get_default() notifd.on_notified = function(_, id) - local n = notifd.get_notification(id) - print(n.body, n.summary) + local n = notifd.get_notification(id) + print(n.body, n.summary) end ``` -- cgit v1.2.3