update documentation for new API

This commit is contained in:
Leon Henrik Plickat
2023-12-30 09:01:52 +01:00
parent ccfaa03839
commit 25fcd37930
2 changed files with 7 additions and 27 deletions

View File

@@ -4,7 +4,7 @@ Layout generator for the [river](https://github.com/riverwm/river) Wayland
server which uses [Guile Scheme](https://www.gnu.org/software/guile/) for server which uses [Guile Scheme](https://www.gnu.org/software/guile/) for
layouts. Its layout namespace is `riverguile`. layouts. Its layout namespace is `riverguile`.
Uppon launch, riverguile tries to eval a scheme script and checks the following Uppon launch, riverguile tries to load a scheme script and checks the following
paths for it in the given order: paths for it in the given order:
* `layout.scm` * `layout.scm`
@@ -12,30 +12,9 @@ paths for it in the given order:
* `$HOME/.config/river/layout.scm` * `$HOME/.config/river/layout.scm`
* `/etc/riverguile/layout.scm` * `/etc/riverguile/layout.scm`
This script must contain the definition of a function In the context of this script, a special procedure `(install-handler key proc)`
`(layout-demand-handler view-count usable-width usable-height)` and is available, which can be used to install handlers to certain events.
may contain any other code the user desires. The function must return Check the man page for more information.
a list containing exactly as many lists as `view-count`. Each of those
sublists must contains exactly four numerical values, which are the x
and y coordinates of the window as well as its width and height.
Window positions and dimensions get applied to rivers
window list top to bottom.
Example of valid output:
```scheme
scheme@(guile-user)> (display (layout-demand-handler 3 1080 1920))
((0 0 594.0 1920) (594.0 0 486.0 960) (594.0 960 486.0 960))
```
Note that the numerical values do not need to be exact, riverguile takes care
of rounding and casting for you.
You can send riverguile layout-commands, which it will try to eval as scheme code.
```sh
riverctl map normal Super U send-layout-cmd riverguile "(define gaps 20)"
```
Here is an example `layout.scm` file replicating rivertiles behavior of having Here is an example `layout.scm` file replicating rivertiles behavior of having
a main window and a stack of windows aside: a main window and a stack of windows aside:
@@ -61,6 +40,6 @@ a main window and a stack of windows aside:
(append (list (list x y left h)) (append (list (list x y left h))
(layout:rows (- n 1) (+ x left) y right h))))) (layout:rows (- n 1) (+ x left) y right h)))))
(define (layout-demand-handler view-count width height) (install-handler 'layout-demand (lambda (view-count width height tags output)
(layout:split view-count 0 0 width height)) (layout:split view-count 0 0 width height)))
``` ```

View File

@@ -50,6 +50,7 @@ the x and y coordinates of the window as well as its width and height.
Window positions and dimensions get applied to rivers window list top to bottom. Window positions and dimensions get applied to rivers window list top to bottom.
Note that the numerical values do not need to be exact, riverguile takes care Note that the numerical values do not need to be exact, riverguile takes care
of rounding and casting for you. of rounding and casting for you.
A layout demand handler must be installed, otherwise riverguile will exit.
.P .P
The key \fBuser-command\fR install a handler for user commands, which are the The key \fBuser-command\fR install a handler for user commands, which are the
strings a user can send to layout generators. strings a user can send to layout generators.