- subscribe conn event thunkprocedure
Subscribes to the specified EVENT (e.g. "workspace") and calls THUNK when an event arrives.
(define (subscribe conn event thunk) (i3-conn-callbacks-set! conn (alist-update! (alist-ref event i3-event-name-to-type string=?) thunk (i3-conn-callbacks conn))) (let ((sock (i3-conn-event-fd conn)) (mutex (i3-conn-evmutex conn))) (mutex-lock! mutex) (socket-send-all sock (i3-format-ipc-message (json->string (vector event)) 2)) (i3-read-one-message sock) (mutex-unlock! mutex)))