add anoia.nl, a convenience wrapper on netlink
This commit is contained in:
15
pkgs/anoia/nl.fnl
Normal file
15
pkgs/anoia/nl.fnl
Normal 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 }
|
7
pkgs/anoia/test-nl.fnl
Normal file
7
pkgs/anoia/test-nl.fnl
Normal file
@@ -0,0 +1,7 @@
|
||||
(local nl (require :anoia.nl))
|
||||
(local { : view } (require :fennel))
|
||||
|
||||
(let [events (nl.events {:link true})]
|
||||
(each [ev events]
|
||||
(print "got one ")
|
||||
(print (view ev))))
|
Reference in New Issue
Block a user