/ src / root.rs
root.rs
 1  //! Root-level files for the FUSE filesystem (README.md, .gitignore).
 2  
 3  use std::path::Path;
 4  
 5  /// Generate README content with the mount path interpolated into examples.
 6  pub fn readme_content(mount_path: &Path) -> String {
 7      let path = mount_path.display();
 8      format!(
 9          r#"# Accessibility Tree Filesystem
10  
11  A FUSE filesystem exposing the AT-SPI accessibility tree.
12  
13  ## Structure
14  
15  ```
16  /
17  ├── .gitignore
18  ├── README.md
19  ├── firefox-1/
20  │   ├── name
21  │   ├── role
22  │   ├── description
23  │   ├── child_count
24  │   ├── states.json
25  │   ├── interfaces.json
26  │   ├── attributes.json
27  │   ├── relations.json
28  │   ├── events.json.sock
29  │   └── frame-42/
30  │       └── ...
31  └── ...
32  ```
33  
34  ## Files
35  
36  Files are omitted when empty or null.
37  
38  | File | Description |
39  |------|-------------|
40  | `name` | Accessible name |
41  | `role` | Role (e.g., "frame", "push button") |
42  | `description` | Description text |
43  | `child_count` | Number of children |
44  | `accessible_id` | Application-specific identifier |
45  | `locale` | Language/locale (e.g., "en_US.UTF-8") |
46  | `help_text` | Extended help text |
47  | `index_in_parent` | Position among siblings (-1 for root) |
48  | `states.json` | Current states (focused, enabled, etc.) |
49  | `interfaces.json` | Implemented AT-SPI interfaces |
50  | `attributes.json` | Custom attributes |
51  | `relations.json` | Relations to other objects |
52  | `events.json.sock` | Unix socket streaming events as JSON lines |
53  
54  Additional interface-specific files (e.g., `text`, `bounds.json`, `actions.json`)
55  appear when the object implements the corresponding AT-SPI interface.
56  
57  ## Directory Names
58  
59  Directories use the format `<name>-<id>`:
60  
61  - **name**: Object's `name` property (lowercase, special chars → `-`), or role if unnamed
62  - **id**: D-Bus bus address for applications (`:1.45` → `1.45`), or object path's
63    last component for children (`/org/a11y/atspi/accessible/2/3/4` → `4`)
64  
65  ## Reading Events
66  
67  Connect to event sockets with:
68  
69  ```sh
70  nc -U {path}/app-1.23/events.json.sock
71  # Or:
72  socat - UNIX-CONNECT:{path}/app-1.23/events.json.sock
73  ```
74  
75  ## Examples
76  
77  Find application directory from event source
78  : Event source `:1.87:` → `find {path} -maxdepth 1 -name '*-1.87'`
79  
80  Find child object within an application
81  : Event source `:1.87:2/3/42` → `find {path}/*-1.87 -name '*-42' -type d`
82  
83  Find focused widget
84  : `grep -rl '"focused"' {path} --include='states.json' | head -1 | xargs dirname`
85  
86  ## Best Practices
87  
88  - **No caching**: Every file read queries AT-SPI directly. For best performance,
89    limit scope of operations (grep, find, etc.) or run them as deep in the tree
90    as possible.
91  "#
92      )
93  }
94  
95  /// .gitignore content (ignore everything in this directory).
96  pub const GITIGNORE: &[u8] = b"*\n";