Update README

This commit is contained in:
Leon Henrik Plickat
2024-01-15 03:04:06 +01:00
parent bd27c22895
commit a5b129d637

View File

@@ -1,28 +1,30 @@
# riverguile # riverguile
Scripting layer for the [river](https://github.com/riverwm/river) Wayland Scripting layer for the [river](https://github.com/riverwm/river) Wayland
server using [Guile Scheme](https://www.gnu.org/software/guile/). server using [Guile Scheme](https://www.gnu.org/software/guile/). Send commands
to river and install handlers for various events, including layout demands.
Send commands to river and install handlers for various events, inclusing The ultimate aim of giverguile is to allow comfortable scripting in the context
layout events. of desktop operations, including window management.
Uppon launch, riverguile tries to load a scheme script and checks the following > "So, the UNIX philosophy is nice and all, but I wish I could script my desktop
paths for it in the given order: > in a way that's a bit more integrated and less hacky."
* `layout.scm` Do you agree with that statement? Do you like Lisp / Scheme? Do you believe
* `$XDG_CONFIG_HOME/river/layout.scm` policy over mechanism is the only sane way to design a scripting API? Then
* `$HOME/.config/river/layout.scm` riverguile might be what you want!
* `/etc/riverguile/layout.scm`
In the context of this script, a special procedure `(install-handler key proc)` Riverguile follows river development closely, exposing new functionality as
is available, which can be used to install handlers to certain events. scheme procedures and advocating for even more scripting features. Right now,
Check the man page for more information. riverguile is implemented as an interpreter for river init scripts.
Here is an example `layout.scm` file replicating rivertiles behavior of having
a main window and a stack of windows aside while also automatically locking
the screen after five minutes of inactivity.
```scheme ```scheme
#!/bin/env riverguile
!#
(use-modules (riverguile))
;; Lock the screen after five minutes and darken the screen.
(install-handler 'idle:300 (lambda (event) (install-handler 'idle:300 (lambda (event)
(cond ((eq? event 'idle) (system "swaylock &") (cond ((eq? event 'idle) (system "swaylock &")
(system "backlight.sh set-to 40")) (system "backlight.sh set-to 40"))
@@ -48,6 +50,8 @@ the screen after five minutes of inactivity.
(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)))))
;; Replicate rivertile.
(R default-layout riverguile)
(install-handler 'layout-demand (lambda (view-count width height tags output) (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)))
``` ```