Fork me on GitHub
#babashka
<
2023-07-25
>
Björn Ebbinghaus11:07:31

Hey, is OBB still the go-to to interact with the macOS/Apple Script/Automator ecosystem, or has anyone perhaps already written a custom lib for BB itself? (I don't know much about it (yet) and wanted to try it out for a hobby project).

borkdude11:07:14

obb = SCI+JS tailered for macOS OSAScript yes

borkdude11:07:50

$ osascript -l JavaScript <<< '1 + 1'
2

Björn Ebbinghaus11:07:54

... Ah … So it's just BB + the Stuff to adapt it to Apple's systems? I should have read the manual: > ## How does this tool work? > ClojureScript code is evaluated through https://github.com/borkdude/sci, the same interpreter that powers https://babashka.org/. SCI is compiled to JavaScript which is then by executed by osascript.

borkdude11:07:06

No it is not bb, bb doesn't use JavaScript

Björn Ebbinghaus11:07:46

What are the limitations to OBB compared to BB? I want to write software that tracks my use of my computer locally and maybe runs a local webserver to display the data I recorded. But I guess it would make sense to separate the "tracking" from the "analytics" anyway.

borkdude12:07:23

> What are the limitations to OBB compared to BB? The host platform is just very different. It's same as asking, what is the limitation of Node.js compared to the JVM

Björn Ebbinghaus12:07:35

Hm… OK, I think I understand. I can't do things like: (spit ...) only interact with the OSA stuff. That's good enough. Is there a nice way to call OBB from BB? Right now, I'm doing:

Björn Ebbinghaus12:07:48

(->> 
 (str `(-> (js/Application "Brave") (.-windows) (aget 0) (.activeTab) (.title)))
 (process/shell {:out :string} "obb" "-e")
 :out)

borkdude12:07:18

yeah, that's what I would do

Björn Ebbinghaus14:07:23

@U04V15CAJ Before I open an issue on GitHub. Do you know what happens here?

❯ obb -e '(.processes (js/Application "System Events"))'
/usr/local/bin/obb: execution error: Error: Error: Typen können nicht konvertiert werden. (-1700)

~
❯ osascript -l JavaScript <<< 'Application("System Events").processes()'
Application("System Events").applicationProcesses.byName("loginwindow"), Application("System Events").applicationProcesses.byName("softwareupdated"),
...

Björn Ebbinghaus14:07:52

Error: Typen können nicht konvertiert werden.
= "Types could not be converted"

borkdude14:07:33

I believe this just has to do with printing:

$ obb -e '(def x (.processes (js/Application "System Events"))) (js/console.log (type x))'
function Array() {
    [native code]
}

borkdude14:07:14

Please continue in the #C02S1220XRV channel

👍 2