From e44cf1b26d1e6fd1c581691c309525390e39c8fe Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Wed, 30 Jul 2025 20:16:08 -0400 Subject: add: new gist --- 2025/2025-07-30-open-observable-desktop.md | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 2025/2025-07-30-open-observable-desktop.md (limited to ':') 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." +``` -- cgit v1.2.3