{"id":13760404,"url":"https://github.com/babashka/obb","last_synced_at":"2025-06-18T17:07:47.465Z","repository":{"id":43292160,"uuid":"443869321","full_name":"babashka/obb","owner":"babashka","description":"Ad-hoc ClojureScript scripting of Mac applications via Apple's Open Scripting Architecture.","archived":false,"fork":false,"pushed_at":"2022-10-23T09:42:51.000Z","size":67,"stargazers_count":244,"open_issues_count":7,"forks_count":5,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-10T10:36:43.614Z","etag":null,"topics":["automation","babashka","clojure","clojurescript","javascript","macos","scripting"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babashka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["zane","borkdude"]}},"created_at":"2022-01-02T21:02:35.000Z","updated_at":"2025-01-20T20:27:43.000Z","dependencies_parsed_at":"2023-01-20T03:04:34.601Z","dependency_job_id":null,"html_url":"https://github.com/babashka/obb","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/babashka/obb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fobb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fobb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fobb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fobb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babashka","download_url":"https://codeload.github.com/babashka/obb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Fobb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260595746,"owners_count":23033790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","babashka","clojure","clojurescript","javascript","macos","scripting"],"created_at":"2024-08-03T13:01:09.655Z","updated_at":"2025-06-18T17:07:42.450Z","avatar_url":"https://github.com/babashka.png","language":"Clojure","readme":"# obb\n\n[![project chat](https://img.shields.io/badge/slack-join_chat-brightgreen.svg)](https://app.slack.com/client/T03RZGPFR/C02S1220XRV)\n![Stability: Experimental](https://img.shields.io/badge/stability-experimental-orange.svg)\n\nAd-hoc [ClojureScript](https://clojurescript.org/) scripting of Mac applications via Apple's [Open Scripting Architecture](https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/).\n\n## Status\n\nExperimental.\n\n## Installation\n\n### Homebrew\n\n``` shell\n$ brew install babashka/brew/obb\n```\n\n### Manual\n\nDownload from [Github releases](https://github.com/babashka/obb/releases).\n\n## Usage\n\nEvaluate an expression:\n\n``` shell\n$ obb -e '(-\u003e (js/Application \"Safari\") (.-documents) (aget 0) (.url))'\n\"https://clojure.org/\"\n```\n\n``` shell\n$ obb -e '(-\u003e (js/Application \"Google Chrome\") (.-windows) (aget 0) (.activeTab) (.title))'\n#js [\"GitHub - babashka/obb: Ad-hoc ClojureScript scripting of Mac applications\"]\n```\n\nOr evaluate a file:\n\n``` shell\n$ obb examples/choice.cljs\n```\n\nOr make an executable script by using `obb` in a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)):\n\n``` clojure\n#!/usr/bin/env obb\n(-\u003e (js/Application \"Safari\")\n    (.quit))\n```\n\n## How does this tool work?\n\nClojureScript code is evaluated through [SCI](https://github.com/borkdude/sci), the same interpreter that powers [babashka](https://babashka.org/). SCI is compiled to JavaScript which is then by executed by `osascript`.\n\n## Macros\n\nSCI supports macros as first class citizens so you can write a few macros to deal with interop boilerplate:\n\n``` clojure\n(defmacro -\u003eclj [obj \u0026 interops]\n  (let [names (map #(clojure.string/replace (str %) #\"[.-]\" \"\") interops)\n        ks (mapv keyword names)\n        exprs (mapv #(list % obj) interops)]\n    `(zipmap ~ks [~@exprs])))\n\n(-\u003e (js/Application \"Spotify\") (.-currentTrack) (-\u003eclj .artist .album .name))\n;;=\u003e\n{:artist \"The Gathering\", :album \"How to Measure a Planet? (Deluxe Edition)\", :name \"Travel\"}\n```\n\n## References\n\n- [Mac Automation Scripting Guide](https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/GettoKnowScriptEditor.html#//apple_ref/doc/uid/TP40016239-CH5-SW1)\n- [JXA Cookbook](https://github.com/JXA-Cookbook/JXA-Cookbook/wiki)\n- [Scripting with JXA](https://bru6.de/jxa/)\n    - [It illustrates a way to find an App's properties and elements.](https://bru6.de/jxa/basics/working-with-apps/#get-an-apps-properties-and-elements)\n\n## Tips and tricks\n\n### Explore app specific APIs\n\nOpen `Script Editor.app`, go to `File` \u003e `Open Dictionary` and select the\napplication you would like to explore, e.g. `Spotify.app`.  After selection,\nselect `JavaScript` instead of `AppleScript`.\n\n### Application bundle\n\nRead [here](doc/application-bundle.md) how to create an application bundle from an obb script.\n\n## Sister projects\n\n- [babashka](https://github.com/babashka/babashka): Native, fast starting Clojure interpreter for scripting.\n- [nbb](https://github.com/babashka/nbb): Ad-hoc CLJS scripting on Node.js using SCI.\n- [scittle](https://github.com/babashka/scittle): The Small Clojure Interpreter exposed for usage in browser script tags.\n\n## Build\n\n[Install Babashka](https://github.com/babashka/babashka/#installation). Then build with:\n\n``` shell\n$ bb build\n```\n\nThen place `out/obb` anywhere on your path.\n\n## Dev\n\nTo develop `obb` you can use the `bb dev` task which starts a shadow-cljs server\nand a file watcher.\n","funding_links":["https://github.com/sponsors/zane","https://github.com/sponsors/borkdude"],"categories":["Clojure"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fobb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabashka%2Fobb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Fobb/lists"}