terml-spawner 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/AGENTS.md +56 -9
- terml_spawner-0.1.2/PKG-INFO +228 -0
- terml_spawner-0.1.2/README.md +219 -0
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/example-session.yaml +3 -2
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/ideas.md +17 -0
- terml_spawner-0.1.2/prompts.md +94 -0
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/pyproject.toml +1 -1
- terml_spawner-0.1.2/src/terml/__init__.py +797 -0
- terml_spawner-0.1.2/tests/test_terml.py +822 -0
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/uv.lock +1 -1
- terml_spawner-0.1.2/worklog.md +387 -0
- terml_spawner-0.1.1/PKG-INFO +0 -142
- terml_spawner-0.1.1/README.md +0 -133
- terml_spawner-0.1.1/prompts.md +0 -31
- terml_spawner-0.1.1/src/terml/__init__.py +0 -414
- terml_spawner-0.1.1/tests/test_terml.py +0 -401
- terml_spawner-0.1.1/worklog.md +0 -150
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/.gitignore +0 -0
- {terml_spawner-0.1.1 → terml_spawner-0.1.2}/.sandbox.cfg +0 -0
|
@@ -28,7 +28,7 @@ for the user-facing behaviour and `ideas.md` for the task list and its rules.
|
|
|
28
28
|
- Real end-to-end checks need the user's host. Not yet confirmed there:
|
|
29
29
|
Pango accepting `8px` as size, ratios in fullscreen windows, `pos` with
|
|
30
30
|
`force-x11: true`, percentages in `pos` / `size` (real `xrandr` output,
|
|
31
|
-
Wayland, display scaling).
|
|
31
|
+
Wayland, display scaling), how close the `c` estimate for `size` gets.
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
## Workflow
|
|
@@ -65,21 +65,68 @@ Pipeline, all pure functions except `user_config`, `system_font`, `spawn`,
|
|
|
65
65
|
primary), parsed by `monitor()`. `xrandr` is only called if a percentage
|
|
66
66
|
is used. Choosing the primary monitor was the agent's decision, the user
|
|
67
67
|
only asked for percentages.
|
|
68
|
-
- The top level of a file is a list of windows or a map (`ROOT_KEYS
|
|
69
|
-
`
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
inherited.
|
|
68
|
+
- The top level of a file is a list of windows or a map (`ROOT_KEYS`).
|
|
69
|
+
`root()` turns a list into `{children: list}`, so both forms take the
|
|
70
|
+
same path. The windows are the resolved children of that root, which is
|
|
71
|
+
how root values get inherited.
|
|
73
72
|
- The file name `-` means stdin (`source()`). Its base for a relative
|
|
74
73
|
`cwd` is the current directory, error messages call it `<stdin>`.
|
|
75
|
-
- The distribution is called `
|
|
76
|
-
package and the command `terml` (there is a `
|
|
77
|
-
`--version` asks `importlib.metadata` for
|
|
74
|
+
- The distribution is called `terml-spawner` (`pyproject.toml`), the
|
|
75
|
+
Python package and the command `terml` (there is a `terml-spawner`
|
|
76
|
+
command, too). `--version` asks `importlib.metadata` for
|
|
77
|
+
`terml-spawner`, so the version is
|
|
78
78
|
only maintained in `pyproject.toml`. Renaming the distribution breaks
|
|
79
79
|
`--version`, `test_version` will tell.
|
|
80
80
|
- `enabled()` drops entries with `disabled: true` at every level. It is
|
|
81
81
|
applied before validation, so disabled entries are neither checked nor
|
|
82
82
|
counted for ratios. It keeps the original index for error messages.
|
|
83
|
+
- `variables` are handled in `resolved()`, not via `INHERITED`, because
|
|
84
|
+
they are merged rather than replaced. Every resolved node carries the
|
|
85
|
+
full map. `substituted()` replaces `${NAME}` in `command`, `cwd` and
|
|
86
|
+
`name`, unknown names stay (they are probably meant for the shell),
|
|
87
|
+
`$${NAME}` is the escape. Values are substituted with the parent's
|
|
88
|
+
variables when defined, so a sibling override later doesn't change them.
|
|
89
|
+
- `no-terminal` entries are resolved by `resolved()` itself (same
|
|
90
|
+
inheritance), stored in every resolved node under `no-terminal` and
|
|
91
|
+
collected by `launches()`. `sessions()` returns the resolved top level
|
|
92
|
+
nodes, `windows()` only their children. `launch()` starts one entry,
|
|
93
|
+
`--print-config` prints them as `# no-terminal ...` comment lines after
|
|
94
|
+
the config.
|
|
95
|
+
- `web-links` are turned into `no-terminal` entries by `links()` inside
|
|
96
|
+
`resolved()`, so they inherit, get substituted and are started (or
|
|
97
|
+
printed) like those. URLs are `shlex.quote`d, browser names are not (they
|
|
98
|
+
may carry options). A plain list uses `BROWSER` (`xdg-open`), one call
|
|
99
|
+
per URL. Imports merge a browser map shallowly: the same browser in a
|
|
100
|
+
later file replaces the earlier URL list.
|
|
101
|
+
- `import` / `try-import` (top level only) are handled by `loaded()`,
|
|
102
|
+
which validates every file on its own (so error messages name the right
|
|
103
|
+
file), then folds imports and the file itself with `merged()`: lists are
|
|
104
|
+
appended, dicts merged, other values replaced, `None` doesn't replace a
|
|
105
|
+
list or dict (`children:` left empty). A disabled file contributes `{}`.
|
|
106
|
+
Relative `cwd` of imported content resolves against the main file,
|
|
107
|
+
because resolution runs after merging - "merged as if written there",
|
|
108
|
+
the agent's interpretation, not yet confirmed by the user.
|
|
109
|
+
- Command line: `arguments()` splits the positional arguments into files
|
|
110
|
+
(leading existing files or `-`) and window names. `selected()` filters
|
|
111
|
+
the windows by resolved `name` and, with names, only takes the
|
|
112
|
+
`no-terminal` entries inside the selected windows (top level ones are
|
|
113
|
+
dropped). Unknown names are errors.
|
|
114
|
+
- Characters in `size` (`80c`) are resolved in `run()` by `sized()`,
|
|
115
|
+
after `placed()`. Allowed units per key are in `UNITS`. The cell size is
|
|
116
|
+
an estimate (`CELL` x font size in pixels, plus `BORDER`), terml can't
|
|
117
|
+
measure the font without GTK / Pango. Font size: the window's
|
|
118
|
+
`font-size`, else `font_size()` of the user's `default` profile (system
|
|
119
|
+
font via gsettings if `use_system_font`). Points become pixels at 96 dpi
|
|
120
|
+
(`POINT`).
|
|
121
|
+
- Ratios in characters (`ratio: 16c`) are turned into percentages by
|
|
122
|
+
`measured()` / `spread()`, called from `scaled()` in `run()` after
|
|
123
|
+
`placed()` and `sized()`. They walk the tree with the extent in pixels
|
|
124
|
+
(window `size` minus `BORDER`, or the monitor for `fullscreen` /
|
|
125
|
+
`maximize`, see `frame()`) and use the child's own `font-size`.
|
|
126
|
+
`layout()` only ever sees percentages. `proportion()` / `greedy()` skip
|
|
127
|
+
character ratios during validation.
|
|
128
|
+
- `marks` (notes) is in `ROOT_KEYS`, `NODE_KEYS` and `APP_KEYS` and
|
|
129
|
+
nowhere else: accepted with any value, never read.
|
|
83
130
|
- `cwd: ~` in YAML is `null`, not a string. `resolved()` maps a `null` cwd
|
|
84
131
|
to home on purpose.
|
|
85
132
|
- YAML `maximize` becomes Terminator's `maximised` (British spelling).
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: terml-spawner
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: YAML based spawner for Terminator
|
|
5
|
+
Requires-Python: >=3.10
|
|
6
|
+
Requires-Dist: configobj>=5.0.8
|
|
7
|
+
Requires-Dist: pyyaml>=6
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
|
|
10
|
+
# terml
|
|
11
|
+
|
|
12
|
+
YAML based spawner for [Terminator](https://github.com/gnome-terminator/terminator):
|
|
13
|
+
describe windows, splits, ratios, font sizes, working directories and commands
|
|
14
|
+
in a YAML file and let `terml` open them all at once.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
terml FILE [FILE ...] # open all windows, return immediately
|
|
20
|
+
terml FILE ... NAME ... # open only the windows with these names
|
|
21
|
+
terml - # read the session from stdin
|
|
22
|
+
terml --print-config FILE ... # show the generated Terminator config
|
|
23
|
+
terml --version
|
|
24
|
+
|
|
25
|
+
Run it from the project folder without installing:
|
|
26
|
+
|
|
27
|
+
uv run terml example-session.yaml
|
|
28
|
+
|
|
29
|
+
Or install it:
|
|
30
|
+
|
|
31
|
+
uv tool install .
|
|
32
|
+
|
|
33
|
+
With `terml` on your `PATH` a session file starting with
|
|
34
|
+
`#!/usr/bin/env terml` can be made executable and started directly.
|
|
35
|
+
|
|
36
|
+
`-` instead of a file reads from stdin, which goes well with a here-document.
|
|
37
|
+
A relative `cwd` is then relative to the current directory:
|
|
38
|
+
|
|
39
|
+
terml - <<'EOF'
|
|
40
|
+
- {command: htop}
|
|
41
|
+
- {cwd: ~/src, children: [{}, {}]}
|
|
42
|
+
EOF
|
|
43
|
+
|
|
44
|
+
Names after the files restrict terml to the windows with that `name`
|
|
45
|
+
(after variable substitution). All windows with a matching name open, plus
|
|
46
|
+
the `no-terminal` entries inside them. Top level `no-terminal` entries are
|
|
47
|
+
skipped then. A name without a window is an error. Arguments count as files
|
|
48
|
+
as long as they are existing files (or `-`), from the first other one on
|
|
49
|
+
they count as names:
|
|
50
|
+
|
|
51
|
+
terml example-session.yaml fred
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Session files
|
|
55
|
+
|
|
56
|
+
The top level is a list. Every entry is a window. An entry with `children`
|
|
57
|
+
is split, an entry without is a terminal. See `example-session.yaml`.
|
|
58
|
+
|
|
59
|
+
The top level may also be a map with the windows as `children`. Next to
|
|
60
|
+
`children` it takes the inherited keys, `disabled`, `variables`,
|
|
61
|
+
`no-terminal`, `import` and `try-import` (see below), which then apply to all
|
|
62
|
+
windows of the file:
|
|
63
|
+
|
|
64
|
+
font-size: 20
|
|
65
|
+
cwd: ~/src
|
|
66
|
+
children:
|
|
67
|
+
- name: first window
|
|
68
|
+
- name: second window
|
|
69
|
+
|
|
70
|
+
A list based example:
|
|
71
|
+
|
|
72
|
+
- name: projects
|
|
73
|
+
size: [400, 800]
|
|
74
|
+
cwd: ~/src
|
|
75
|
+
children:
|
|
76
|
+
- command: htop
|
|
77
|
+
ratio: 30%
|
|
78
|
+
- split: horizontal
|
|
79
|
+
children:
|
|
80
|
+
- command: git status
|
|
81
|
+
- font-size: 8px
|
|
82
|
+
|
|
83
|
+
| Key | Where | Meaning |
|
|
84
|
+
|---------------|-----------|--------------------------------------------------|
|
|
85
|
+
| `name` | window | window title |
|
|
86
|
+
| `pos` | window | `[x, y]` in pixels or percent (see limitations) |
|
|
87
|
+
| `size` | window | `[width, height]` in pixels, percent or |
|
|
88
|
+
| | | characters (`80c`, an estimate, see below) |
|
|
89
|
+
| `fullscreen` | window | `true` makes the window fullscreen |
|
|
90
|
+
| `maximize` | window | `true` maximizes the window |
|
|
91
|
+
| `force-x11` | window | `true` starts Terminator with `GDK_BACKEND=x11` |
|
|
92
|
+
| `children` | anywhere | list of nested entries |
|
|
93
|
+
| `split` | anywhere | how `children` are arranged: `vertical` stacks |
|
|
94
|
+
| | | them top to bottom (default), `horizontal` puts |
|
|
95
|
+
| | | them side by side |
|
|
96
|
+
| `ratio` | child | share of the space left over by the children |
|
|
97
|
+
| | | before it, e.g. `40%`, or characters: `16c` |
|
|
98
|
+
| `command` | terminal | command to run in an interactive `$SHELL` |
|
|
99
|
+
| `cwd` | inherited | working directory |
|
|
100
|
+
| `font-size` | inherited | `8` means points, `8px` means pixels |
|
|
101
|
+
| `keep` | inherited | `true` (default): drop into a shell after the |
|
|
102
|
+
| | | command. `false`: Terminator decides, by default |
|
|
103
|
+
| | | the terminal closes |
|
|
104
|
+
| `disabled` | anywhere | `true` ignores the entry and all its children |
|
|
105
|
+
| `variables` | anywhere | map of names to values, see below |
|
|
106
|
+
| `no-terminal` | anywhere | list of programs to start without a terminal |
|
|
107
|
+
| `web-links` | anywhere | URLs to open in a browser, see below |
|
|
108
|
+
| `import` | top level | list of session files to merge in, see below |
|
|
109
|
+
| `try-import` | top level | like `import`, missing files are skipped |
|
|
110
|
+
| `marks` | anywhere | notes, any value, ignored by terml |
|
|
111
|
+
|
|
112
|
+
Details:
|
|
113
|
+
|
|
114
|
+
- "inherited" keys apply to all children unless a child overrides them.
|
|
115
|
+
- Children are placed in the order they are written. `ratio` is a share of
|
|
116
|
+
what the children before left over: `50%`, `50%`, rest gives 50%, 25% and
|
|
117
|
+
25% of the parent. The last child always takes the rest, its `ratio` is
|
|
118
|
+
ignored.
|
|
119
|
+
- A child without `ratio` takes an equal share: one third of the rest if
|
|
120
|
+
three children are still to be placed (itself included). So children
|
|
121
|
+
without any `ratio` split their parent equally.
|
|
122
|
+
- `ratio: 16c` gives a child 16 characters (rows when stacked, columns
|
|
123
|
+
side by side) in its own `font-size`. That's the same estimate as for
|
|
124
|
+
`size` and needs a window with `size`, `fullscreen` or `maximize`, since
|
|
125
|
+
terml has to know the space it divides. For `fullscreen` and `maximize`
|
|
126
|
+
that's the whole primary monitor (`xrandr`).
|
|
127
|
+
- A relative `cwd` is relative to the parent's `cwd`, or to the session file
|
|
128
|
+
at the top level. `cwd: ~` means home.
|
|
129
|
+
- Note that `vertical` and `horizontal` name the direction in which the
|
|
130
|
+
children are laid out. Terminator's menu names it the other way round.
|
|
131
|
+
- Commands run via `$SHELL -ic`, so `.bashrc` / `.zshrc` are sourced and
|
|
132
|
+
your functions and aliases are available.
|
|
133
|
+
- `pos` and `size` accept percentages, also mixed with pixels:
|
|
134
|
+
`size: [300, 100%]`. They refer to the primary monitor as reported by
|
|
135
|
+
`xrandr`, to its full size including panels and docks. A `pos` in
|
|
136
|
+
percent starts at the top left corner of that monitor, a `pos` in pixels
|
|
137
|
+
at the top left corner of the whole desktop.
|
|
138
|
+
- `size` also takes characters: `size: [80c, 24c]`, mixable with pixels
|
|
139
|
+
and percent. That's an estimate: a character is taken as 0.6 x 1.25 of
|
|
140
|
+
the window's `font-size` (or the size of your `default` profile's font),
|
|
141
|
+
plus a guessed border for scrollbar, padding and title bar. Splits are
|
|
142
|
+
not taken into account, `80c` is the width of the whole window.
|
|
143
|
+
- A `disabled` entry is treated as if it wasn't there: it takes no space,
|
|
144
|
+
and its content isn't even checked.
|
|
145
|
+
- `variables` work like inherited keys, but are merged: a child adds names
|
|
146
|
+
or overrides single ones, the rest stays. terml replaces `${NAME}` in
|
|
147
|
+
`command`, `cwd` and `name`. Names terml doesn't know stay untouched, so
|
|
148
|
+
`${HOME}` still reaches the shell. `$${NAME}` gives a literal `${NAME}`.
|
|
149
|
+
A value may use the variables of the parents:
|
|
150
|
+
|
|
151
|
+
variables: {HARNESS: opencode}
|
|
152
|
+
children:
|
|
153
|
+
- variables: {RUN: "${HARNESS} --continue"}
|
|
154
|
+
command: ${RUN}
|
|
155
|
+
- `no-terminal` starts programs without a terminal, e.g. GUI apps, so one
|
|
156
|
+
session file can replace other launchers. Entries take `command`, `cwd`,
|
|
157
|
+
`variables` and `disabled`, and inherit `cwd` and `variables` from where
|
|
158
|
+
they are written. They are started detached via `$SHELL -ic`, after the
|
|
159
|
+
terminals. They take no space: an entry holding nothing but `no-terminal`
|
|
160
|
+
still opens a terminal. For apps only, use the top level map:
|
|
161
|
+
|
|
162
|
+
no-terminal:
|
|
163
|
+
- command: gedit
|
|
164
|
+
- command: firefox
|
|
165
|
+
- `web-links` opens URLs, either as a list (each via `xdg-open`, so in
|
|
166
|
+
your default browser) or as a map of browser commands to lists of URLs
|
|
167
|
+
(one call per browser with all its URLs). They are started like
|
|
168
|
+
`no-terminal` entries and follow the same rules:
|
|
169
|
+
|
|
170
|
+
web-links:
|
|
171
|
+
firefox --new-window:
|
|
172
|
+
- https://example.org
|
|
173
|
+
- https://${HOST}/status
|
|
174
|
+
chromium:
|
|
175
|
+
- https://example.com
|
|
176
|
+
- In `{...}` flow style, quote values with variables: `{command: "${APP}"}`.
|
|
177
|
+
Otherwise YAML takes the `{` for the start of a map.
|
|
178
|
+
- `import` and `try-import` merge other session files into this one, as if
|
|
179
|
+
their content was written here. The order: `import` files, `try-import`
|
|
180
|
+
files, then the file itself. Lists (`children`, `no-terminal`) are
|
|
181
|
+
appended, so imported windows come first. `variables` are merged. Other
|
|
182
|
+
values: the later one wins, so the importing file has the last word:
|
|
183
|
+
|
|
184
|
+
import: [common.yaml]
|
|
185
|
+
try-import: [~/.config/terml/local.yaml]
|
|
186
|
+
variables: {HARNESS: opencode}
|
|
187
|
+
children:
|
|
188
|
+
- command: ${HARNESS}
|
|
189
|
+
- Import paths are relative to the file that names them (for stdin: the
|
|
190
|
+
current directory). Imported files may import, cycles are errors.
|
|
191
|
+
`try-import` only skips missing files, broken ones still fail.
|
|
192
|
+
- A relative `cwd` in an imported file is relative to the importing file,
|
|
193
|
+
since its content counts as written there.
|
|
194
|
+
- `marks` is for notes. terml ignores it, so it may hold anything, e.g. a
|
|
195
|
+
markdown block for whoever reads the file:
|
|
196
|
+
|
|
197
|
+
- name: projects
|
|
198
|
+
marks: |
|
|
199
|
+
## projects
|
|
200
|
+
*htop* on top, `git status` below
|
|
201
|
+
- Unknown keys are errors.
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
## How it works
|
|
205
|
+
|
|
206
|
+
`terml` copies your Terminator config (`~/.config/terminator/config`), adds a
|
|
207
|
+
layout `terml` plus one profile per font size (copies of your `default`
|
|
208
|
+
profile), writes the result to `$XDG_RUNTIME_DIR/terml/` and starts
|
|
209
|
+
|
|
210
|
+
terminator --no-dbus --config <generated config> --layout terml
|
|
211
|
+
|
|
212
|
+
Your own config is never modified.
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
## Limitations
|
|
216
|
+
|
|
217
|
+
- `pos` is ignored on Wayland unless `force-x11: true` is set for the window.
|
|
218
|
+
- Percentages need `xrandr`. With display scaling the pixels reported by
|
|
219
|
+
`xrandr` may not be the pixels Terminator counts in.
|
|
220
|
+
- Windows opened by `terml` run in their own Terminator process without DBus.
|
|
221
|
+
`remotinator` and `terminator --new-tab` don't reach them.
|
|
222
|
+
- Preferences saved from within such a window end up in the generated config
|
|
223
|
+
and are gone after logout.
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## Development
|
|
227
|
+
|
|
228
|
+
uv run pytest
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# terml
|
|
2
|
+
|
|
3
|
+
YAML based spawner for [Terminator](https://github.com/gnome-terminator/terminator):
|
|
4
|
+
describe windows, splits, ratios, font sizes, working directories and commands
|
|
5
|
+
in a YAML file and let `terml` open them all at once.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
terml FILE [FILE ...] # open all windows, return immediately
|
|
11
|
+
terml FILE ... NAME ... # open only the windows with these names
|
|
12
|
+
terml - # read the session from stdin
|
|
13
|
+
terml --print-config FILE ... # show the generated Terminator config
|
|
14
|
+
terml --version
|
|
15
|
+
|
|
16
|
+
Run it from the project folder without installing:
|
|
17
|
+
|
|
18
|
+
uv run terml example-session.yaml
|
|
19
|
+
|
|
20
|
+
Or install it:
|
|
21
|
+
|
|
22
|
+
uv tool install .
|
|
23
|
+
|
|
24
|
+
With `terml` on your `PATH` a session file starting with
|
|
25
|
+
`#!/usr/bin/env terml` can be made executable and started directly.
|
|
26
|
+
|
|
27
|
+
`-` instead of a file reads from stdin, which goes well with a here-document.
|
|
28
|
+
A relative `cwd` is then relative to the current directory:
|
|
29
|
+
|
|
30
|
+
terml - <<'EOF'
|
|
31
|
+
- {command: htop}
|
|
32
|
+
- {cwd: ~/src, children: [{}, {}]}
|
|
33
|
+
EOF
|
|
34
|
+
|
|
35
|
+
Names after the files restrict terml to the windows with that `name`
|
|
36
|
+
(after variable substitution). All windows with a matching name open, plus
|
|
37
|
+
the `no-terminal` entries inside them. Top level `no-terminal` entries are
|
|
38
|
+
skipped then. A name without a window is an error. Arguments count as files
|
|
39
|
+
as long as they are existing files (or `-`), from the first other one on
|
|
40
|
+
they count as names:
|
|
41
|
+
|
|
42
|
+
terml example-session.yaml fred
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## Session files
|
|
46
|
+
|
|
47
|
+
The top level is a list. Every entry is a window. An entry with `children`
|
|
48
|
+
is split, an entry without is a terminal. See `example-session.yaml`.
|
|
49
|
+
|
|
50
|
+
The top level may also be a map with the windows as `children`. Next to
|
|
51
|
+
`children` it takes the inherited keys, `disabled`, `variables`,
|
|
52
|
+
`no-terminal`, `import` and `try-import` (see below), which then apply to all
|
|
53
|
+
windows of the file:
|
|
54
|
+
|
|
55
|
+
font-size: 20
|
|
56
|
+
cwd: ~/src
|
|
57
|
+
children:
|
|
58
|
+
- name: first window
|
|
59
|
+
- name: second window
|
|
60
|
+
|
|
61
|
+
A list based example:
|
|
62
|
+
|
|
63
|
+
- name: projects
|
|
64
|
+
size: [400, 800]
|
|
65
|
+
cwd: ~/src
|
|
66
|
+
children:
|
|
67
|
+
- command: htop
|
|
68
|
+
ratio: 30%
|
|
69
|
+
- split: horizontal
|
|
70
|
+
children:
|
|
71
|
+
- command: git status
|
|
72
|
+
- font-size: 8px
|
|
73
|
+
|
|
74
|
+
| Key | Where | Meaning |
|
|
75
|
+
|---------------|-----------|--------------------------------------------------|
|
|
76
|
+
| `name` | window | window title |
|
|
77
|
+
| `pos` | window | `[x, y]` in pixels or percent (see limitations) |
|
|
78
|
+
| `size` | window | `[width, height]` in pixels, percent or |
|
|
79
|
+
| | | characters (`80c`, an estimate, see below) |
|
|
80
|
+
| `fullscreen` | window | `true` makes the window fullscreen |
|
|
81
|
+
| `maximize` | window | `true` maximizes the window |
|
|
82
|
+
| `force-x11` | window | `true` starts Terminator with `GDK_BACKEND=x11` |
|
|
83
|
+
| `children` | anywhere | list of nested entries |
|
|
84
|
+
| `split` | anywhere | how `children` are arranged: `vertical` stacks |
|
|
85
|
+
| | | them top to bottom (default), `horizontal` puts |
|
|
86
|
+
| | | them side by side |
|
|
87
|
+
| `ratio` | child | share of the space left over by the children |
|
|
88
|
+
| | | before it, e.g. `40%`, or characters: `16c` |
|
|
89
|
+
| `command` | terminal | command to run in an interactive `$SHELL` |
|
|
90
|
+
| `cwd` | inherited | working directory |
|
|
91
|
+
| `font-size` | inherited | `8` means points, `8px` means pixels |
|
|
92
|
+
| `keep` | inherited | `true` (default): drop into a shell after the |
|
|
93
|
+
| | | command. `false`: Terminator decides, by default |
|
|
94
|
+
| | | the terminal closes |
|
|
95
|
+
| `disabled` | anywhere | `true` ignores the entry and all its children |
|
|
96
|
+
| `variables` | anywhere | map of names to values, see below |
|
|
97
|
+
| `no-terminal` | anywhere | list of programs to start without a terminal |
|
|
98
|
+
| `web-links` | anywhere | URLs to open in a browser, see below |
|
|
99
|
+
| `import` | top level | list of session files to merge in, see below |
|
|
100
|
+
| `try-import` | top level | like `import`, missing files are skipped |
|
|
101
|
+
| `marks` | anywhere | notes, any value, ignored by terml |
|
|
102
|
+
|
|
103
|
+
Details:
|
|
104
|
+
|
|
105
|
+
- "inherited" keys apply to all children unless a child overrides them.
|
|
106
|
+
- Children are placed in the order they are written. `ratio` is a share of
|
|
107
|
+
what the children before left over: `50%`, `50%`, rest gives 50%, 25% and
|
|
108
|
+
25% of the parent. The last child always takes the rest, its `ratio` is
|
|
109
|
+
ignored.
|
|
110
|
+
- A child without `ratio` takes an equal share: one third of the rest if
|
|
111
|
+
three children are still to be placed (itself included). So children
|
|
112
|
+
without any `ratio` split their parent equally.
|
|
113
|
+
- `ratio: 16c` gives a child 16 characters (rows when stacked, columns
|
|
114
|
+
side by side) in its own `font-size`. That's the same estimate as for
|
|
115
|
+
`size` and needs a window with `size`, `fullscreen` or `maximize`, since
|
|
116
|
+
terml has to know the space it divides. For `fullscreen` and `maximize`
|
|
117
|
+
that's the whole primary monitor (`xrandr`).
|
|
118
|
+
- A relative `cwd` is relative to the parent's `cwd`, or to the session file
|
|
119
|
+
at the top level. `cwd: ~` means home.
|
|
120
|
+
- Note that `vertical` and `horizontal` name the direction in which the
|
|
121
|
+
children are laid out. Terminator's menu names it the other way round.
|
|
122
|
+
- Commands run via `$SHELL -ic`, so `.bashrc` / `.zshrc` are sourced and
|
|
123
|
+
your functions and aliases are available.
|
|
124
|
+
- `pos` and `size` accept percentages, also mixed with pixels:
|
|
125
|
+
`size: [300, 100%]`. They refer to the primary monitor as reported by
|
|
126
|
+
`xrandr`, to its full size including panels and docks. A `pos` in
|
|
127
|
+
percent starts at the top left corner of that monitor, a `pos` in pixels
|
|
128
|
+
at the top left corner of the whole desktop.
|
|
129
|
+
- `size` also takes characters: `size: [80c, 24c]`, mixable with pixels
|
|
130
|
+
and percent. That's an estimate: a character is taken as 0.6 x 1.25 of
|
|
131
|
+
the window's `font-size` (or the size of your `default` profile's font),
|
|
132
|
+
plus a guessed border for scrollbar, padding and title bar. Splits are
|
|
133
|
+
not taken into account, `80c` is the width of the whole window.
|
|
134
|
+
- A `disabled` entry is treated as if it wasn't there: it takes no space,
|
|
135
|
+
and its content isn't even checked.
|
|
136
|
+
- `variables` work like inherited keys, but are merged: a child adds names
|
|
137
|
+
or overrides single ones, the rest stays. terml replaces `${NAME}` in
|
|
138
|
+
`command`, `cwd` and `name`. Names terml doesn't know stay untouched, so
|
|
139
|
+
`${HOME}` still reaches the shell. `$${NAME}` gives a literal `${NAME}`.
|
|
140
|
+
A value may use the variables of the parents:
|
|
141
|
+
|
|
142
|
+
variables: {HARNESS: opencode}
|
|
143
|
+
children:
|
|
144
|
+
- variables: {RUN: "${HARNESS} --continue"}
|
|
145
|
+
command: ${RUN}
|
|
146
|
+
- `no-terminal` starts programs without a terminal, e.g. GUI apps, so one
|
|
147
|
+
session file can replace other launchers. Entries take `command`, `cwd`,
|
|
148
|
+
`variables` and `disabled`, and inherit `cwd` and `variables` from where
|
|
149
|
+
they are written. They are started detached via `$SHELL -ic`, after the
|
|
150
|
+
terminals. They take no space: an entry holding nothing but `no-terminal`
|
|
151
|
+
still opens a terminal. For apps only, use the top level map:
|
|
152
|
+
|
|
153
|
+
no-terminal:
|
|
154
|
+
- command: gedit
|
|
155
|
+
- command: firefox
|
|
156
|
+
- `web-links` opens URLs, either as a list (each via `xdg-open`, so in
|
|
157
|
+
your default browser) or as a map of browser commands to lists of URLs
|
|
158
|
+
(one call per browser with all its URLs). They are started like
|
|
159
|
+
`no-terminal` entries and follow the same rules:
|
|
160
|
+
|
|
161
|
+
web-links:
|
|
162
|
+
firefox --new-window:
|
|
163
|
+
- https://example.org
|
|
164
|
+
- https://${HOST}/status
|
|
165
|
+
chromium:
|
|
166
|
+
- https://example.com
|
|
167
|
+
- In `{...}` flow style, quote values with variables: `{command: "${APP}"}`.
|
|
168
|
+
Otherwise YAML takes the `{` for the start of a map.
|
|
169
|
+
- `import` and `try-import` merge other session files into this one, as if
|
|
170
|
+
their content was written here. The order: `import` files, `try-import`
|
|
171
|
+
files, then the file itself. Lists (`children`, `no-terminal`) are
|
|
172
|
+
appended, so imported windows come first. `variables` are merged. Other
|
|
173
|
+
values: the later one wins, so the importing file has the last word:
|
|
174
|
+
|
|
175
|
+
import: [common.yaml]
|
|
176
|
+
try-import: [~/.config/terml/local.yaml]
|
|
177
|
+
variables: {HARNESS: opencode}
|
|
178
|
+
children:
|
|
179
|
+
- command: ${HARNESS}
|
|
180
|
+
- Import paths are relative to the file that names them (for stdin: the
|
|
181
|
+
current directory). Imported files may import, cycles are errors.
|
|
182
|
+
`try-import` only skips missing files, broken ones still fail.
|
|
183
|
+
- A relative `cwd` in an imported file is relative to the importing file,
|
|
184
|
+
since its content counts as written there.
|
|
185
|
+
- `marks` is for notes. terml ignores it, so it may hold anything, e.g. a
|
|
186
|
+
markdown block for whoever reads the file:
|
|
187
|
+
|
|
188
|
+
- name: projects
|
|
189
|
+
marks: |
|
|
190
|
+
## projects
|
|
191
|
+
*htop* on top, `git status` below
|
|
192
|
+
- Unknown keys are errors.
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
## How it works
|
|
196
|
+
|
|
197
|
+
`terml` copies your Terminator config (`~/.config/terminator/config`), adds a
|
|
198
|
+
layout `terml` plus one profile per font size (copies of your `default`
|
|
199
|
+
profile), writes the result to `$XDG_RUNTIME_DIR/terml/` and starts
|
|
200
|
+
|
|
201
|
+
terminator --no-dbus --config <generated config> --layout terml
|
|
202
|
+
|
|
203
|
+
Your own config is never modified.
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Limitations
|
|
207
|
+
|
|
208
|
+
- `pos` is ignored on Wayland unless `force-x11: true` is set for the window.
|
|
209
|
+
- Percentages need `xrandr`. With display scaling the pixels reported by
|
|
210
|
+
`xrandr` may not be the pixels Terminator counts in.
|
|
211
|
+
- Windows opened by `terml` run in their own Terminator process without DBus.
|
|
212
|
+
`remotinator` and `terminator --new-tab` don't reach them.
|
|
213
|
+
- Preferences saved from within such a window end up in the generated config
|
|
214
|
+
and are gone after logout.
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
uv run pytest
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
- {} # just starts a sub-terminal running the shell
|
|
23
23
|
|
|
24
24
|
# more complex screen setup
|
|
25
|
-
- name:
|
|
25
|
+
- name: ${WHO} # variables work in name, cwd and command
|
|
26
|
+
variables: {WHO: fred}
|
|
26
27
|
fullscreen: true
|
|
27
28
|
cwd: ~/_HEAP/mark
|
|
28
29
|
children:
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
ratio: 40% # takes 40% of vertical space
|
|
31
32
|
children:
|
|
32
33
|
- ratio: 30% # uses 30% of available space
|
|
33
|
-
command: banner
|
|
34
|
+
command: banner ${WHO}
|
|
34
35
|
- command: ls -alF
|
|
35
36
|
- ratio: 50% # takes 50% of the rest (30% of the window)
|
|
36
37
|
- {} # takes the rest of the available vertical space, starts the shell
|
|
@@ -9,14 +9,31 @@ Don't implement items marked with `[?]` automatically - skip them or stop.
|
|
|
9
9
|
Items marked with `[!]` should be planned carefully, ask questions, skip them
|
|
10
10
|
for now if other more obvious items exist.
|
|
11
11
|
|
|
12
|
+
|
|
12
13
|
## tasks
|
|
13
14
|
|
|
15
|
+
- [ ] fail on non-existing paths
|
|
16
|
+
- [ ] don't instantiate already existing named items per default.
|
|
17
|
+
`existing: ignore` allows multiple instantiation
|
|
18
|
+
`existing: overwrite` kills existing instances
|
|
19
|
+
`existing: skip` (default)
|
|
14
20
|
- [ ] `terml --reuse <FILE>*` uses current terminal window (if given)
|
|
15
21
|
- needs Terminator's DBus API (`remotinator`), which cannot set ratios,
|
|
16
22
|
cwd, font size, window position or size - see AGENTS.md
|
|
17
23
|
- [ ] virtual desktop support
|
|
18
24
|
- [ ] convenient tmux support (`tmux: true` runs a tmux session for element)
|
|
25
|
+
- [ ] wait for commands to be executed (`sandbox ..`, `sandbox enter ..`)
|
|
26
|
+
|
|
19
27
|
|
|
20
28
|
## done
|
|
21
29
|
|
|
22
30
|
- [x] 2026-12-01: project scaffolding: YAML based spawner for `terminator`
|
|
31
|
+
- [x] 2026-12-01: die on unknown keys to avoid mis-configuration
|
|
32
|
+
- [x] 2026-12-01: support variables
|
|
33
|
+
- [x] 2026-12-01: support non-terminal spawns
|
|
34
|
+
- [x] 2026-12-01: support `import` and `try-import`
|
|
35
|
+
- [x] 2026-12-01: `terml <FILE*> <NAME*>` restricts to `<NAMES>`
|
|
36
|
+
- [x] 2026-12-01: allow for arbitrary notes via `marks`
|
|
37
|
+
- [x] 2026-12-01: for `size` support unit `c` (character)
|
|
38
|
+
- [x] 2026-12-01: `ratio` allows `c` size, too
|
|
39
|
+
- [x] 2026-12-01: `web-links`, open URLs in specify-able browser
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# terml prompts
|
|
2
|
+
|
|
3
|
+
* 2026.12.01-10:30: read @ideas.md and @example-session.yaml, ask questions and
|
|
4
|
+
make a plan
|
|
5
|
+
* 2026.12.01-10:54: make sure bashrc zshrc are being executed as they would
|
|
6
|
+
normally - e.g. I have a function `banner` defined which currently can't be
|
|
7
|
+
executed (not found). also: add 'maximize' (same rules as 'fullscreen',
|
|
8
|
+
applicable on top elements only), which maximizes the window (without
|
|
9
|
+
fullscreen)
|
|
10
|
+
* 2026.12.01-11:10: commit your changes separately
|
|
11
|
+
* 2026.12.01-11:12: Committing per prompt it is!
|
|
12
|
+
* 2026.12.01-11:50: add an `disabled: <bool>` attribute (which plainly ignores
|
|
13
|
+
the whole item and it's sub-items)
|
|
14
|
+
* 2026.12.01-11:56: read items in the order found in the yaml and treat `ratio`
|
|
15
|
+
as 'part of the rest', so ratio 50% / ratio 50% will give the first element
|
|
16
|
+
50% of the space, the second 50% of the rest (25%) if there are further
|
|
17
|
+
elements (ignored if thre are none)
|
|
18
|
+
* 2026.12.01-11:58: accept percentages in pos/size (even mixed), so
|
|
19
|
+
`size: [300, 100%]` will result in width 300px horizontally, and 100%
|
|
20
|
+
vertically
|
|
21
|
+
* 2026.12.01-12:01: allow a top level map, too: `children: [..]` at top-level
|
|
22
|
+
would make it the same as a top level list. top level
|
|
23
|
+
`{font: 20, children: [..]}` would apply font to all windows then
|
|
24
|
+
* 2026.12.01-12:03: add support for reading from stdin:
|
|
25
|
+
```
|
|
26
|
+
terml - <<'EOF'
|
|
27
|
+
- {..}
|
|
28
|
+
- {..}
|
|
29
|
+
EOF
|
|
30
|
+
```
|
|
31
|
+
* 2026.12.01-12:11: implement --version
|
|
32
|
+
* 2026.12.01-13:10: implement the easy topics from ideas.md, questions?
|
|
33
|
+
* 2026.12.01-13:15: (ideas.md) die on unknown keys to avoid mis-configuration
|
|
34
|
+
* 2026.12.01-13:16: (ideas.md) support variables, e.g.
|
|
35
|
+
```
|
|
36
|
+
variables:
|
|
37
|
+
HARNESS: opencode
|
|
38
|
+
children:
|
|
39
|
+
- command: echo ${HARNESS}
|
|
40
|
+
```
|
|
41
|
+
* 2026.12.01-13:18: (ideas.md) support non-terminal spawns, too in order to not
|
|
42
|
+
having to use different launchers, e.g.
|
|
43
|
+
```
|
|
44
|
+
no-terminal:
|
|
45
|
+
- command: gedit
|
|
46
|
+
- command: chrome
|
|
47
|
+
- command: firefox
|
|
48
|
+
- command: signal
|
|
49
|
+
```
|
|
50
|
+
* 2026.12.01-13:20: (ideas.md) support `import` and `try-import`
|
|
51
|
+
```
|
|
52
|
+
import:
|
|
53
|
+
- path/to/file1
|
|
54
|
+
- path/to/file2
|
|
55
|
+
try-import:
|
|
56
|
+
- path/to/local-settings.yaml
|
|
57
|
+
children:
|
|
58
|
+
- command: echo ${HARNESS}
|
|
59
|
+
```
|
|
60
|
+
- order matters: conflicting items are overwritten, `children` and maps are
|
|
61
|
+
merged
|
|
62
|
+
- variables defined in imported files should be inherited (and overwritten
|
|
63
|
+
in order of import)
|
|
64
|
+
* 2026.12.01-13:43: add an `disabled: <bool>` attribute (which plainly ignores
|
|
65
|
+
the whole item and it's sub-items)
|
|
66
|
+
* 2026.12.01-14:58: go ahead, next items from ideas.md (ask questions where
|
|
67
|
+
needed)
|
|
68
|
+
* 2026.12.01-15:05: (ideas.md) `terml <FILE*> <NAME*>` restricts to
|
|
69
|
+
`<NAMES>` (error if not found) try positional arguments as files first,
|
|
70
|
+
then names
|
|
71
|
+
* 2026.12.01-15:10: (ideas.md) allow for arbitrary notes via `marks` (no
|
|
72
|
+
function, but markdown highlighted)
|
|
73
|
+
* 2026.12.01-15:12: (ideas.md) for `size` support unit `c` (character) which
|
|
74
|
+
depends on font-size
|
|
75
|
+
* 2026.12.01-15:24: next two items, please
|
|
76
|
+
* 2026.12.01-15:28: read ideas.md and implement next two items, please
|
|
77
|
+
* 2026.12.01-15:28: (ideas.md) `ratio` allows `c` size, too, so `ratio: 16c`
|
|
78
|
+
splits after 16 characters
|
|
79
|
+
* 2026.12.01-15:30: (ideas.md) similar to `no-terminal`: `web-links`, open
|
|
80
|
+
URLs in specify-able browser
|
|
81
|
+
```
|
|
82
|
+
web-links:
|
|
83
|
+
- URL1
|
|
84
|
+
- URL2
|
|
85
|
+
```
|
|
86
|
+
```
|
|
87
|
+
web-links:
|
|
88
|
+
firefox:
|
|
89
|
+
- URL1
|
|
90
|
+
- URL2
|
|
91
|
+
crome:
|
|
92
|
+
- URL3
|
|
93
|
+
- URL4
|
|
94
|
+
```
|