Skip to content

Commit 22318aa

Browse files
committed
wip: narrowing in on some osx hangs
plus some clj-kondo configs
1 parent 3f9a283 commit 22318aa

5 files changed

Lines changed: 79 additions & 11 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{:hooks
2+
{:analyze-call
3+
{next.jdbc/with-transaction
4+
hooks.com.github.seancorfield.next-jdbc/with-transaction
5+
next.jdbc/with-transaction+options
6+
hooks.com.github.seancorfield.next-jdbc/with-transaction+options}}
7+
:lint-as {next.jdbc/on-connection clojure.core/with-open
8+
next.jdbc/on-connection+options clojure.core/with-open}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
(ns hooks.com.github.seancorfield.next-jdbc
2+
(:require [clj-kondo.hooks-api :as api]))
3+
4+
(defn with-transaction
5+
"Expands (with-transaction [tx expr opts] body)
6+
to (let [tx expr] opts body) per clj-kondo examples."
7+
[{:keys [:node]}]
8+
(let [[binding-vec & body] (rest (:children node))
9+
[sym val opts] (:children binding-vec)]
10+
(when-not (and sym val)
11+
(throw (ex-info "No sym and val provided" {})))
12+
(let [new-node (api/list-node
13+
(list*
14+
(api/token-node 'let)
15+
(api/vector-node [sym val])
16+
opts
17+
body))]
18+
{:node new-node})))
19+
20+
(defn with-transaction+options
21+
"Expands (with-transaction+options [tx expr opts] body)
22+
to (let [tx expr] opts body) per clj-kondo examples."
23+
[{:keys [:node]}]
24+
(let [[binding-vec & body] (rest (:children node))
25+
[sym val opts] (:children binding-vec)]
26+
(when-not (and sym val)
27+
(throw (ex-info "No sym and val provided" {})))
28+
(let [new-node (api/list-node
29+
(list*
30+
(api/token-node 'let)
31+
(api/vector-node [sym val])
32+
opts
33+
body))]
34+
{:node new-node})))

src/clawe/wm.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
(defn current-workspaces
138138
([] (current-workspaces nil))
139139
([opts]
140+
(timer/print-since "current-workspaces start")
140141
(sys/start! `*wm*)
141142
(->>
142143
(wm.protocol/-current-workspaces *wm* opts)
@@ -148,6 +149,7 @@
148149
(defn current-workspace
149150
([] (current-workspace nil))
150151
([opts]
152+
(timer/print-since "current-workspace start")
151153
(sys/start! `*wm*)
152154
(some->> (current-workspaces opts) first)))
153155

@@ -203,7 +205,11 @@
203205
(defn active-clients
204206
([] (active-clients nil))
205207
([opts]
208+
(timer/print-since "clawe.wm/active-clients started")
209+
206210
(sys/start! `*wm*)
211+
212+
(timer/print-since "*wm* started")
207213
(->>
208214
(wm.protocol/-active-clients *wm* opts)
209215
(map merge-with-client-def))))

src/clawe/yabai.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
;; TODO refactor into malli transforms?
99
(defn window->clawe-client
10-
[{:yabai.window/keys [has-focus app title window-id] :as window}]
10+
[{:yabai.window/keys [has-focus app title id] :as window}]
1111
(-> window
12-
(assoc :client/id window-id)
12+
(assoc :client/id id)
1313
(assoc :client/focused has-focus)
1414
(assoc :client/window-title (some-> title string/lower-case))
1515
(assoc :client/app-name (some-> app string/lower-case))))

src/ralphie/yabai.clj

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,37 @@
201201
[:yabai.window/has-border boolean?]
202202
[:yabai.window/can-resize boolean?]])
203203

204+
(def minimal-wm-fields
205+
(string/join
206+
" " ["id"
207+
"app"
208+
"has-focus"
209+
"space"
210+
"is-sticky"
211+
"title"
212+
"is-floating"]))
213+
204214
;; TODO does this have a format-string/read-edn style?
205215
;; TODO refactor to use these malli schemas
206-
(defn query-windows []
207-
(try
208-
(->
209-
^{:out :string}
210-
(process/$ yabai -m query --windows)
211-
process/check
212-
:out
213-
(json/parse-string (fn [k] (keyword "yabai.window" k))))
214-
(catch Exception _e nil)))
216+
(defn query-windows
217+
([] (query-windows nil))
218+
([{:keys [fields]}]
219+
(println "yabai query-windows start")
220+
(let [fields (if (nil? fields) nil minimal-wm-fields)
221+
windows
222+
(try
223+
(->
224+
^{:out :string}
225+
(process/$ yabai -m query --windows ~fields)
226+
process/check
227+
:out
228+
(json/parse-string (fn [k] (keyword "yabai.window" k))))
229+
(catch Exception e
230+
(println "yabai query-windows exception" e)
231+
nil))]
232+
(println "yabai query-windows found dows" windows)
233+
windows
234+
)))
215235

216236
(comment
217237
(query-windows)

0 commit comments

Comments
 (0)