| wayland-bar-compositor: a wlroots compositor in jolt, for panels on X11 1d16366 nandi 8d ago | 1 | #!/usr/bin/env jolt |
| 2 | ;; Generate offsets.edn: the wlroots struct layout facts wayland-bar-compositor |
| 3 | ;; reads at startup. Rerun after a wlroots update. |
| 4 | |
| 5 | (require '[babashka.process :as p] |
| 6 | '[babashka.fs :as fs] |
| 7 | '[clojure.string :as str]) |
| 8 | |
| 9 | (def here (str (fs/parent (fs/canonicalize *file*)))) |
| 10 | (def out (str here "/build-out")) |
| 11 | (fs/create-dirs out) |
| 12 | |
| 13 | (defn run [& cmd] |
| 14 | (apply p/shell {:out :inherit :err :inherit} cmd)) |
| 15 | |
| 16 | ;; wlroots' public layer-shell header includes a protocol header it doesn't install. |
| 17 | (run "wayland-scanner" "server-header" |
| 18 | (str here "/protocol/wlr-layer-shell-unstable-v1.xml") |
| 19 | (str out "/wlr-layer-shell-unstable-v1-protocol.h")) |
| 20 | |
| 21 | (def cflags (-> (p/sh "pkg-config" "--cflags" "wlroots-0.20" "wayland-server" "pixman-1" "xkbcommon") :out str/trim)) |
| 22 | |
| 23 | (apply run (concat ["cc" "-o" (str out "/gen-offsets") (str here "/gen-offsets.c") (str "-I" out)] |
| 24 | (str/split cflags #"\s+"))) |
| 25 | |
| 26 | (spit (str here "/offsets.edn") (:out (p/sh (str out "/gen-offsets")))) |
| 27 | (println "wrote" (str here "/offsets.edn")) |