Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
WilfSilver committed May 14, 2022
1 parent 6a59835 commit f88ed0b
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions docs/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,50 @@ Eww then reads the provided value and renders the resulting widget. Whenever it

Note that this is not all that efficient. Make sure to only use `literal` when necessary!

## Dynamically generated windows with arguments and ids

In some cases you may want to use the same window configuration for multiple widgets, e.g. for multiple windows. This is where arugments and ids come in.

Firstly let us start off with ids. An id can be specified in the `open` command with `--id`, by default the id will be set to the name of the window configuration. These ids allow you to spawn multiple of the same windows. So for example you can do:

```bash
eww open my_bar --screen 0 --id primary
eww open my_bar --screen 1 --id secondary
```

However you may want to have slight changes for each of these bars, e.g. spawning other windows on the same monitor. This is where the arguments come in.

Defining arguments in a window is the exact same as in a widget so you can have:

```lisp
(defwindow my_bar [arg1 ?arg2]
:geometry (geometry
:x "0%"
:y "6px"
:width "100%"
:height "30px"
:anchor "top center")
:stacking "bg"
:windowtype "dock"
:reserve (struts :distance "50px" :side "top")
...)
```

Here we have two arguments, `arg1` and `arg2` (an optional parameter).

Once we have these parameters, when opening a new window, we must specify them (unless they are required, like `arg2`), but how? Well, we use the `--args` option when running the `open` command:

```bash
eww open my_bar --id primary --args arg1=some_value,arg2=another_value
```

You may notice that this is the same layout to set values with `update` and you'd be correct.

So, now you know the basics, I shall introduce you to some of these "special" parameters, which are set slightly differently. However these can all be overridden by the `--args` option.

- `id` - If `id` is included in the argument list, it will be set to the id specified by `--id` or will be set to the name of the config. This can be used when closing the current window through eww commands.
- `screen` - If `screen` is specified it will be set to the value given by `--screen`, so you can use this in other widgets to access screen specific information.

## Generating a list of widgets from JSON using `for`

If you want to display a list of values, you can use the `for`-Element to fill a container with a list of elements generated from a JSON-array.
Expand Down

0 comments on commit f88ed0b

Please sign in to comment.