2023-06-29 18:13:15 +03:00
|
|
|
Ironbar includes a simple IPC server which can be used to control it programmatically at runtime.
|
|
|
|
|
|
|
|
It also includes a command line interface, which can be used for interacting with the IPC server.
|
|
|
|
|
|
|
|
# CLI
|
|
|
|
|
|
|
|
This is shipped as part of the `ironbar` binary. To view commands, you can use `ironbar --help`.
|
2024-05-18 19:17:26 +03:00
|
|
|
You can also view help per sub-command or command, for example using `ironbar var --help` or `ironbar var set --help`.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
The CLI supports plaintext and JSON output. Plaintext will:
|
|
|
|
|
|
|
|
- Print `ok` for empty success responses
|
|
|
|
- Print the returned body for success responses
|
|
|
|
- Print `error` to followed by the error on the next line for error responses. This is printed to `stderr`.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```shell
|
2024-05-18 19:17:26 +03:00
|
|
|
$ ironbar var set subject world
|
2023-06-29 18:13:15 +03:00
|
|
|
ok
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
$ ironbar var get subject
|
2023-06-29 18:13:15 +03:00
|
|
|
world
|
2024-05-18 19:17:26 +03:00
|
|
|
|
|
|
|
$ ironbar var get foo
|
|
|
|
error
|
|
|
|
Variable not found
|
2023-06-29 18:13:15 +03:00
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
All error responses will cause the CLI to exit code 3.
|
|
|
|
|
2023-06-29 18:13:15 +03:00
|
|
|
# IPC
|
|
|
|
|
|
|
|
The server listens on a Unix socket.
|
2024-05-18 19:17:26 +03:00
|
|
|
The path is printed on startup, and can usually be found at `/run/user/$UID/ironbar-ipc.sock`.
|
|
|
|
|
|
|
|
Commands and responses are sent as JSON objects.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Commands will have a `command` key, and a `subcommand` key when part of a sub-command.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
|
|
|
The message buffer is currently limited to `1024` bytes.
|
|
|
|
Particularly large messages will be truncated or cause an error.
|
|
|
|
|
2023-07-16 23:07:31 +03:00
|
|
|
The full spec can be found below.
|
|
|
|
|
|
|
|
## Libraries
|
|
|
|
|
|
|
|
- [Luajit](https://github.com/A-Cloud-Ninja/ironbar-ipc-luajit) - Maintained by [@A-Cloud-Ninja](https://github.com/A-Cloud-Ninja)
|
|
|
|
|
2023-06-29 18:13:15 +03:00
|
|
|
## Commands
|
|
|
|
|
|
|
|
### `ping`
|
|
|
|
|
|
|
|
Sends a ping request to the IPC.
|
|
|
|
|
|
|
|
Responds with `ok`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "ping"
|
2023-06-29 18:13:15 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### `inspect`
|
|
|
|
|
|
|
|
Opens the GTK inspector window.
|
|
|
|
|
|
|
|
Responds with `ok`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "inspect"
|
2023-06-29 18:13:15 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-07-01 02:05:12 +03:00
|
|
|
### `reload`
|
|
|
|
|
|
|
|
Restarts the bars, reloading the config in the process.
|
|
|
|
|
|
|
|
The IPC server and main GTK application are untouched.
|
|
|
|
|
|
|
|
Responds with `ok`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "reload"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### `load_css`
|
|
|
|
|
|
|
|
Loads an additional CSS stylesheet, with hot-reloading enabled.
|
|
|
|
|
|
|
|
Responds with `ok` if the stylesheet exists, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "load_css",
|
|
|
|
"path": "/path/to/style.css"
|
2023-07-01 02:05:12 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
### `var`
|
|
|
|
|
|
|
|
Subcommand for controlling Ironvars.
|
|
|
|
|
|
|
|
#### `get`
|
2023-06-29 18:13:15 +03:00
|
|
|
|
2024-04-14 01:08:45 +03:00
|
|
|
Gets an [ironvar](ironvars) value.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
|
|
|
Responds with `ok_value` if the value exists, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "var",
|
|
|
|
"subcommand": "get",
|
2023-06-29 18:13:15 +03:00
|
|
|
"key": "foo"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `set`
|
2023-06-29 18:13:15 +03:00
|
|
|
|
|
|
|
Sets an [ironvar](ironvars) value.
|
|
|
|
|
|
|
|
Responds with `ok`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "var",
|
|
|
|
"subcommand": "set",
|
2023-06-29 18:13:15 +03:00
|
|
|
"key": "foo",
|
|
|
|
"value": "bar"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `list`
|
2024-04-14 01:08:45 +03:00
|
|
|
|
|
|
|
Gets a list of all [ironvar](ironvars) values.
|
|
|
|
|
|
|
|
Responds with `ok_value`.
|
|
|
|
|
|
|
|
Each key/value pair is on its own `\n` separated newline. The key and value are separated by a colon and space `: `.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "var",
|
|
|
|
"subcommand": "list"
|
2024-04-14 01:08:45 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
### `bar`
|
2023-06-29 18:13:15 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `show`
|
2023-06-29 18:13:15 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Forces a bar to be shown, regardless of the current visibility state.
|
2023-06-29 18:13:15 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "show",
|
|
|
|
"name": "bar-123"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### `hide`
|
|
|
|
|
|
|
|
Forces a bar to be hidden, regardless of the current visibility state.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "hide",
|
|
|
|
"name": "bar-123"
|
2023-06-29 18:13:15 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `set_visible`
|
2023-07-13 01:17:04 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Sets a bar's visibility to one of shown/hidden.
|
2023-07-13 01:17:04 +03:00
|
|
|
|
|
|
|
Responds with `ok` if the bar exists, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "set_visible",
|
|
|
|
"name": "bar-123",
|
2023-07-13 01:17:04 +03:00
|
|
|
"visible": true
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `toggle_visible`
|
|
|
|
|
|
|
|
Toggles the current visibility state of a bar between shown and hidden.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "toggle_visible",
|
|
|
|
"name": "bar-123"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### `get_visible`
|
2023-07-13 01:17:04 +03:00
|
|
|
|
|
|
|
Gets a bar's visibility.
|
|
|
|
|
|
|
|
Responds with `ok_value` and the visibility (`true`/`false`) if the bar exists, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "get_visible",
|
|
|
|
"name": "bar-123"
|
2023-07-13 01:17:04 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `show_popup`
|
2023-07-16 20:57:00 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Sets a module's popup open, regardless of its current state.
|
2023-07-16 20:57:00 +03:00
|
|
|
Since each bar only has a single popup, any open popup on the bar is closed.
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Responds with `ok` if the bar and widget exist, otherwise `error`.
|
2023-07-16 20:57:00 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "show_popup",
|
|
|
|
"name": "bar-123",
|
|
|
|
"widget_name": "clock"
|
2023-07-16 20:57:00 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `hide_popup`
|
2023-07-16 20:57:00 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Sets the popup on a bar closed, regardless of which module it is open for.
|
|
|
|
|
|
|
|
Responds with `ok` if the bar and widget exist, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "hide_popup",
|
|
|
|
"bar_name": "bar-123"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### `set_popup_visible`
|
|
|
|
|
|
|
|
Sets a popup's visibility to one of shown/hidden.
|
|
|
|
|
|
|
|
Responds with `ok` if the bar and widget exist, otherwise `error`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "set_popup_visible",
|
|
|
|
"name": "bar-123",
|
|
|
|
"widget_name": "clock",
|
|
|
|
"visible": true
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### `toggle_popup`
|
|
|
|
|
|
|
|
Toggles the open/closed state for a module's popup.
|
2023-07-16 20:57:00 +03:00
|
|
|
Since each bar only has a single popup, any open popup on the bar is closed.
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Responds with `ok` if the bar and widget exist, otherwise `error`.
|
2023-07-16 20:57:00 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "toggle_popup",
|
2023-07-16 22:09:22 +03:00
|
|
|
"bar_name": "bar-123",
|
2024-05-18 19:17:26 +03:00
|
|
|
"widget_name": "clock"
|
2023-07-16 20:57:00 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
#### `get_popup_visible`
|
2023-07-16 20:57:00 +03:00
|
|
|
|
2024-05-18 19:17:26 +03:00
|
|
|
Gets the popup's current visibility state.
|
2023-07-16 20:57:00 +03:00
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
2024-05-18 19:17:26 +03:00
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "get_popup_visible",
|
2023-07-16 22:09:22 +03:00
|
|
|
"bar_name": "bar-123"
|
2023-07-16 20:57:00 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2024-06-13 23:42:40 +03:00
|
|
|
#### `set_exclusive`
|
|
|
|
|
|
|
|
Sets whether the bar reserves an exclusive zone.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"command": "bar",
|
|
|
|
"subcommand": "set_exclusive",
|
|
|
|
"exclusive": true
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-06-29 18:13:15 +03:00
|
|
|
## Responses
|
|
|
|
|
|
|
|
### `ok`
|
|
|
|
|
|
|
|
The operation completed successfully, with no response data.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "ok"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### `ok_value`
|
|
|
|
|
|
|
|
The operation completed successfully, with response data.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "ok_value",
|
|
|
|
"value": "lorem ipsum"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### `error`
|
|
|
|
|
|
|
|
The operation failed.
|
|
|
|
|
|
|
|
Message is optional.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "error",
|
|
|
|
"message": "lorem ipsum"
|
|
|
|
}
|
|
|
|
```
|