aboutsummaryrefslogtreecommitdiff
path: root/2025/2025-07-30-open-observable-desktop.md
diff options
context:
space:
mode:
authorhrbrmstr <bob@rud.is>2025-07-30 20:16:08 -0400
committerhrbrmstr <bob@rud.is>2025-07-30 20:16:08 -0400
commite44cf1b26d1e6fd1c581691c309525390e39c8fe (patch)
treead7a2ac5c8689525c1ec6eb6f66f2d19b15c228a /2025/2025-07-30-open-observable-desktop.md
parentf937a52525b0f849b594527e102a261b48f487ae (diff)
add: new gist
Diffstat (limited to '2025/2025-07-30-open-observable-desktop.md')
-rw-r--r--2025/2025-07-30-open-observable-desktop.md72
1 files changed, 72 insertions, 0 deletions
diff --git a/2025/2025-07-30-open-observable-desktop.md b/2025/2025-07-30-open-observable-desktop.md
new file mode 100644
index 0000000..679a65a
--- /dev/null
+++ b/2025/2025-07-30-open-observable-desktop.md
@@ -0,0 +1,72 @@
+Helper script to open Observable Notebook 2.0 files in Observable Desktop until the HQ team adds that into the app.
+
+```bash
+#!/usr/bin/env bash
+
+# Script to open Observable Desktop and navigate to a specified file
+# This script automates the File -> Open…. menu navigation
+# Usage: ./open_observable.sh [file_path]
+# If no file path is provided, defaults to histheat index.html
+
+if [ $# -eq 0 ]; then
+ FILE_PATH="/Users/hrbrmstr/observable/histheat/docs/index.html"
+ echo "No file path provided. Using default: $FILE_PATH"
+else
+ # Convert relative path to absolute path if needed
+ if [[ "$1" = /* ]]; then
+ FILE_PATH="$1"
+ else
+ FILE_PATH="$(pwd)/$1"
+ fi
+ echo "Opening file: $FILE_PATH"
+fi
+
+if [ ! -f "$FILE_PATH" ]; then
+ echo "Error: File does not exist: $FILE_PATH"
+ echo "Usage: $0 [file_path]"
+ echo " file_path can be absolute or relative to current directory"
+ echo " If no file_path provided, uses default histheat index.html"
+ exit 1
+fi
+
+echo "Opening Observable Desktop and navigating to file..."
+echo "Note: Make sure Observable Desktop has accessibility permissions if prompted"
+
+osascript -e 'tell application "Observable Desktop" to activate'
+sleep 1
+
+osascript -e '
+tell application "System Events"
+ tell process "Observable Desktop"
+ -- Click on File menu
+ click menu bar item "File" of menu bar 1
+ delay 0.5
+
+ -- Click on Open... menu item
+ click menu item "Open…" of menu "File" of menu bar item "File" of menu bar 1
+ delay 2
+ end tell
+end tell'
+
+sleep 1
+
+osascript -e '
+tell application "System Events"
+ -- Use Cmd+Shift+G to open "Go to folder" dialog
+ keystroke "g" using {command down, shift down}
+ delay 1
+
+ -- Type the full path to the file
+ keystroke "'"$FILE_PATH"'"
+ delay 0.5
+
+ -- Press Enter to navigate to the file
+ keystroke return
+ delay 1
+
+ -- Press Enter again to open the file
+ keystroke return
+end tell'
+
+echo "Done! The Observable file should now be open."
+```