add anoia.nl, a convenience wrapper on netlink

This commit is contained in:
Daniel Barlow
2024-03-04 23:01:19 +00:00
parent 35909c9a23
commit 5184ff63f7
3 changed files with 40 additions and 22 deletions

15
pkgs/anoia/nl.fnl Normal file
View File

@@ -0,0 +1,15 @@
(local netlink (require :netlink))
(local { : view } (require :fennel))
(fn events [groups]
(let [sock (netlink.socket)]
(coroutine.wrap
(fn []
(each [_ e (ipairs (sock:query groups))]
(coroutine.yield e))
(while (sock:poll)
(each [_ e (ipairs (sock:event))]
(coroutine.yield e)))))))
{ : events }