Skip to content

Commit 4035974

Browse files
authored
update some formatting, add 'default widgets' and remote shell widgets section for custom widgets doc (#1837)
1 parent 7bad4b3 commit 4035974

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

docs/docs/customwidgets.mdx

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This `WidgetConfigType` is shared between all types of widgets. That is to say,
6666

6767
The other options are part of the inner `MetaTSType` (outlined in blue in the image). This contains all of the details about how the widget actually works. The valid keys vary with each type of widget. They will be individually explored in more detail below.
6868

69-
# Terminal and CLI Widgets
69+
## Terminal and CLI Widgets
7070

7171
A terminal widget, or CLI widget, is a widget that simply opens a terminal and runs a CLI command. They tend to look something like the example below:
7272

@@ -80,7 +80,7 @@ A terminal widget, or CLI widget, is a widget that simply opens a terminal and r
8080
"blockdef": {
8181
"meta": {
8282
"view": "term",
83-
"controller": "cmd"
83+
"controller": "cmd",
8484
"cmd": "<the actual cli command>"
8585
}
8686
}
@@ -110,7 +110,7 @@ The `WidgetConfigType` takes the usual options common to all widgets. The `MetaT
110110
| "term:localshellpath" | (optional) Sets the shell used for running your widget command. Only works locally. If left blank, wave will determine your system default instead. |
111111
| "term:localshellopts" | (optional) Sets the shell options meant to be used with `"term:localshellpath"`. This is useful if you are using a nonstandard shell and need to provide a specific option that we do not cover. Only works locally. Defaults to an empty string. |
112112

113-
## Example Shell Widgets
113+
### Example Local Shell Widgets
114114

115115
If you have multiple shells installed on your machine, there may be times when you want to use a non-default shell. For cases like this, it is easy to create a widget for each.
116116

@@ -172,7 +172,29 @@ It is possible that `pwsh` is not in your path. If this is true, using `"pwsh"`
172172
Windows. but it may be different on your system. Also note that both `pwsh.exe` and `pwsh` work on Windows, but only `pwsh` works on Unix systems.
173173
:::
174174

175-
## Example Cmd Widgets
175+
### Example Remote Shell Widgets
176+
177+
If you want to open a terminal widget for a particular connection (SSH or WSL), you can use the `connection` meta key. The connection key's value should match connections.json (or what's in your connections dropdown menu). Note that you should only use the canonical name (do not use any custom "display:name" that you've set). For WSL that might look like `wsl://Ubuntu`, and for SSH connections that might look like `user@remotehostname`.
178+
179+
```json
180+
{
181+
<... other widgets go here ...>,
182+
"remote-term": {
183+
"icon": "rectangle-terminal",
184+
"label": "remote",
185+
"blockdef": {
186+
"meta": {
187+
"view": "term",
188+
"controller": "shell",
189+
"connection": "<connection>"
190+
}
191+
}
192+
},
193+
<... other widgets go here ...>
194+
}
195+
```
196+
197+
### Example Cmd Widgets
176198

177199
Here are a few simple cmd widgets to serve as examples.
178200

@@ -227,7 +249,7 @@ This adds an icon to the widget bar that you can press to launch a terminal runn
227249

228250
Because this is a TUI app that does not return anything when closed, the `"cmd:clearonstart"` option doesn't change the behavior, so it has been excluded.
229251

230-
# Web Widgets
252+
## Web Widgets
231253

232254
Sometimes, it is desireable to open a page directly to a website. That can easily be accomplished by creating a custom `"web"` widget. They have the following form in general:
233255

@@ -256,7 +278,7 @@ The `WidgetConfigType` takes the usual options common to all widgets. The `MetaT
256278
| "url" | This string is the url of the current page. As part of a widget, it will serve as the page the widget starts at. If not specified, this will default to the globally configurable `"web:defaulturl"` which is [https://github.com/wavetermdev/waveterm](https://github.com/wavetermdev/waveterm) on a fresh install. |
257279
| "pinnedurl" | (optional) This string is the url the homepage button will take you to. If not specified, this will default to the globally configurable `"web:defaulturl"` which is [https://github.com/wavetermdev/waveterm](https://github.com/wavetermdev/waveterm) on a fresh install. |
258280

259-
## Example Web Widgets
281+
### Example Web Widgets
260282

261283
Say you want a widget that automatically starts at YouTube and will use YouTube as the home page. This can be done using:
262284

@@ -304,7 +326,7 @@ Alternatively, say you want a web widget that opens to github as if it were a bo
304326
This adds an icon to the widget bar that you can press to launch a web widget on the github homepage.
305327
![The example speedtest widget](./img/widget-example-github.webp)
306328

307-
# Sysinfo Widgets
329+
## Sysinfo Widgets
308330

309331
The Sysinfo Widget is intentionally kept to a very small subset of possible values that we will expand over time. But it is still possible to configure your own version of it&mdash;for instance, if you want to load a different plot by default. The general form of this widget is:
310332

@@ -334,7 +356,7 @@ The `WidgetConfigType` takes the usual options common to all widgets. The `MetaT
334356
| "graph:numpoints" | The maximum amount of points that can be shown on the graph. Equivalently, the number of seconds the graph window covers. This defaults to 100.|
335357
| "sysinfo:type" | A string representing the collection of types to show on the graph. Valid values for this are `"CPU"`, `"Mem"`, `"CPU + Mem"`, and `All CPU`. Note that these are case sensitive. If no value is provided, the plot will default to showing `"CPU"`.|
336358

337-
## Example Sysinfo Widgets
359+
### Example Sysinfo Widgets
338360

339361
Suppose you have a build process that lasts 3 minutes and you'd like to be able to see the entire build on the sysinfo graph. Also, you would really like to view both the cpu and memory since both are impacted by this process. In that case, you can set up a widget as follows:
340362

@@ -381,3 +403,17 @@ Now, suppose you are fine with the default 100 points (and 100 seconds) but woul
381403
This adds an icon to the widget bar that you can press to launch All CPU plots by default.
382404

383405
![The example speedtest widget](./img/widget-example-all-cpu.webp)
406+
407+
## Overriding Default Widgets
408+
409+
Wave ships with 5 default widgets in the widgets bar (terminal, files, web, ai, and sysinfo). You can modify or remove these by overriding their config in widgets.json. The names of the 5 widgets, in order, are:
410+
411+
- `defwidget@terminal`
412+
- `defwidget@files`
413+
- `defwidget@web`
414+
- `defwidget@ai`
415+
- `defwidget@sysinfo`
416+
417+
To remove any of them, just set that key to `null` in your widgets.json file.
418+
419+
To see their definitions, to copy/paste them, or to understand how they work, you can view all of their definitions on [GitHub - default widgets.json](https://github.com/wavetermdev/waveterm/blob/main/pkg/wconfig/defaultconfig/widgets.json)

0 commit comments

Comments
 (0)