1(import [contextlib [contextmanager]])
2(require [hy.contrib.walk [let]])
3
4(with-decorator contextmanager
5 (defn temp-event [conn name callable]
6 (let [e (conn.register-event name callable)]
7 (try
8 (yield)
9 (finally
10 (conn.unregister-event e))))))
11
12(with-decorator contextmanager
13 (defn same-property [conn property]
14 (setv invoked False)
15 (let [handler (fn [_] (setv invoked True))
16 id (conn.observe-property property handler)]
17 (try
18 (while True
19 (yield)
20 (if invoked
21 (setv invoked False)
22 (break)))
23 (finally (conn.unobserve-property id))))))
24
25(defn same-song [conn]
26 (same-property conn "path"))