aboutsummaryrefslogtreecommitdiff
path: root/2025/2025-07-30-open-observable-desktop.md
blob: 679a65ae13d989f69957e94cb5fec9a14b45161d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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."
```