Add scheme module
This commit is contained in:
7
Makefile
7
Makefile
@@ -3,6 +3,7 @@ SCANNER := wayland-scanner
|
|||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
BINDIR=$(PREFIX)/bin
|
BINDIR=$(PREFIX)/bin
|
||||||
DATADIR=$(PREFIX)/share
|
DATADIR=$(PREFIX)/share
|
||||||
|
MODULEDIR=$(DATADIR)/guile/3.0
|
||||||
MANDIR=$(DATADIR)/man
|
MANDIR=$(DATADIR)/man
|
||||||
|
|
||||||
CFLAGS=-g -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter $\
|
CFLAGS=-g -Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter $\
|
||||||
@@ -42,12 +43,14 @@ $(OBJ): $(GEN)
|
|||||||
|
|
||||||
|
|
||||||
install: riverguile
|
install: riverguile
|
||||||
install -D riverguile $(DESTDIR)$(BINDIR)/riverguile
|
install -D riverguile $(DESTDIR)$(BINDIR)/riverguile
|
||||||
install -m 644 -D doc/riverguile.1 $(DESTDIR)$(MANDIR)/man1/riverguile.1
|
install -m 644 -D doc/riverguile.1 $(DESTDIR)$(MANDIR)/man1/riverguile.1
|
||||||
|
install -m 644 -D module/riverguile.scm $(DESTDIR)$(MODULEDIR)/riverguile.scm
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) $(DESTDIR)$(BINDIR)/riverguile
|
$(RM) $(DESTDIR)$(BINDIR)/riverguile
|
||||||
$(RM) $(DESTDIR)$(MANDIR)/man1/riverguile.1
|
$(RM) $(DESTDIR)$(MANDIR)/man1/riverguile.1
|
||||||
|
$(RM) $(DESTDIR)$(MODULEDIR)/riverguile.scm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) riverguile
|
$(RM) riverguile
|
||||||
|
|||||||
127
doc/riverguile.1
127
doc/riverguile.1
@@ -1,4 +1,4 @@
|
|||||||
.TH RIVERGUILE 1 2023-11-25 "git.sr.ht/~leon_plickat/riverguile" "General Commands Manual"
|
.TH RIVERGUILE 1 2024-01-13 "git.sr.ht/~leon_plickat/riverguile" "General Commands Manual"
|
||||||
.
|
.
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.P
|
.P
|
||||||
@@ -62,24 +62,10 @@ terminal emulator:
|
|||||||
.EE
|
.EE
|
||||||
.RE
|
.RE
|
||||||
.P
|
.P
|
||||||
To make using this procedure more ergonomic you likely want to wrap it in a
|
Riverguile also provides a scheme module which exports macros that wrap this
|
||||||
macro like this:
|
procedure in a more ergonomic interface.
|
||||||
.P
|
This module is documented in the \fBRIVERGUILE MODULE\fR section of this
|
||||||
.RS
|
document.
|
||||||
.EX
|
|
||||||
(\fBdefine-syntax\fR R
|
|
||||||
(\fBsyntax-rules\fR ()
|
|
||||||
((R first) (riverctl (\fBsymbol->string\fR 'first)))
|
|
||||||
((R first . rest) (\fBapply\fR riverctl
|
|
||||||
(\fBmap\fR \fBsymbol->string\fR
|
|
||||||
(\fBappend\fR '(first) 'rest))))))
|
|
||||||
|
|
||||||
(R spawn foot)
|
|
||||||
(R spawn \fB#{\fRnotify-send notification!\fB}#\fR)
|
|
||||||
.EE
|
|
||||||
.RE
|
|
||||||
.P
|
|
||||||
This macro can of course be further modified to suit your specific needs.
|
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.SH EVENT HANDLERS
|
.SH EVENT HANDLERS
|
||||||
@@ -232,7 +218,110 @@ Here is an example which adds a message to the system log on exit:
|
|||||||
.EE
|
.EE
|
||||||
.RE
|
.RE
|
||||||
.RE
|
.RE
|
||||||
|
.
|
||||||
|
.
|
||||||
|
.SH RIVERGUILE MODULE
|
||||||
|
.P
|
||||||
|
A complete installation of riverguile also provides a scheme module which
|
||||||
|
exposes macros and procedures with the intention of exposing more ergonomic
|
||||||
|
interfaces.
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
.EX
|
||||||
|
(\fBuse-modules\fR (riverguile))
|
||||||
|
.EE
|
||||||
|
.RE
|
||||||
|
.P
|
||||||
|
This module is not necessary to use riverguile and also will not provide any
|
||||||
|
of riverguiles functionality to any scheme script not executed by riverguile.
|
||||||
|
.P
|
||||||
|
The following documents all exported procedures and macros.
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
(\fBR\fR \fIarg\fR ...)
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
A direct wrapper for the \fBriverctl\fR procedure, however it also accepts
|
||||||
|
symbols and numbers in addition to strings.
|
||||||
|
Any expressions you need evaluated must be unquoted.
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
.EX
|
||||||
|
(R spawn foot)
|
||||||
|
(R spawn "notify-send hello")
|
||||||
|
|
||||||
|
(\fBfor-each\fR (\fBlambda\fR (cmd) (R spawn ,cmd))
|
||||||
|
'("foot" "firefox" "nautilus"))
|
||||||
|
.EE
|
||||||
|
.RE
|
||||||
|
.RE
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
(\fBR:map\fR \fImode\fR (\fImod\fR \fIkey\fR \fIcmd\fR ...) ...)
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
This macro is intended to simplify defining keymaps.
|
||||||
|
Please refer to the
|
||||||
|
.BR riverctl (1)
|
||||||
|
manual page for more details and specifics regarding rivers map mechanism.
|
||||||
|
Any expressions you need evaluated must be unquoted.
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
.EX
|
||||||
|
(R:map normal
|
||||||
|
(Super H focus-view left)
|
||||||
|
(Super Space spawn foot)
|
||||||
|
(-repeat None XF86AudioRaiseVolume spawn "volume.sh raise 5%"))
|
||||||
|
|
||||||
|
(\fBfor-each\fR (\fBlambda\fR (mode)
|
||||||
|
(R:map ,mode
|
||||||
|
(None XF86MonBrightnessUp spawn "light -A 5")
|
||||||
|
(None XF86MonBrightnessDown spawn "light -U 5")))
|
||||||
|
'("normal" "locked"))
|
||||||
|
.EE
|
||||||
|
.RE
|
||||||
|
.RE
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
(\fBR:input\fR \fIname\fR (\fIval\fR \fIvar\fR ...) ...)
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
This macro is intended to simplify input device configuration.
|
||||||
|
Please refer to the
|
||||||
|
.BR riverctl (1)
|
||||||
|
manual page for details and specifics regarding the input device configuration.
|
||||||
|
Any expressions you need evaluated must be unquoted.
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
.EX
|
||||||
|
(R:input pointer-1149-4128-Kensington_Expert_mouse
|
||||||
|
(accel-profile none)
|
||||||
|
(pointer-accel 0.6)
|
||||||
|
(scroll-method button)
|
||||||
|
(scroll-button BTN_SIDE))
|
||||||
|
.EE
|
||||||
|
.RE
|
||||||
|
.RE
|
||||||
|
.
|
||||||
|
.P
|
||||||
|
(\fBR:keyboard-group\fR \fIname\fR . \fIdevices\fR)
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
This macro is intended to simplify creation of keyboard groups.
|
||||||
|
Please refer to the
|
||||||
|
.BR riverctl (1)
|
||||||
|
manual page for details and specifics regarding keyboard groups.
|
||||||
|
Any expressions you need evaluated must be unquoted.
|
||||||
|
.P
|
||||||
|
.RS
|
||||||
|
.EX
|
||||||
|
(R:keyboard-group split
|
||||||
|
keyboard-XXXX-XXXX-Device-1
|
||||||
|
keyboard-XXXX-XXXX-Device-2
|
||||||
|
keyboard-XXXX-XXXX-Device-3)
|
||||||
|
.EE
|
||||||
|
.RE
|
||||||
|
.RE
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
|
|||||||
68
module/riverguile.scm
Normal file
68
module/riverguile.scm
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
;;;
|
||||||
|
;;; This file if part of riverguile, the scheme powered scripting layer for
|
||||||
|
;;; the river Wayland desktop.
|
||||||
|
;;;
|
||||||
|
;;; Copyright (C) 2024 Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de>
|
||||||
|
;;;
|
||||||
|
;;; This library is free software; you can redistribute it and/or
|
||||||
|
;;; modify it under the terms of the GNU Lesser General Public
|
||||||
|
;;; License version 3 as published by the Free Software Foundation.
|
||||||
|
;;;
|
||||||
|
;;; This library is distributed in the hope that it will be useful,
|
||||||
|
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
;;; Lesser General Public License for more details.
|
||||||
|
;;;
|
||||||
|
;;; You should have received a copy of the GNU Lesser General Public
|
||||||
|
;;; License along with this library; if not, write to the Free Software
|
||||||
|
;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
;; This module provides helper macros and procedures for riverguile and will not
|
||||||
|
;; be useful in any other context. The contents of this module are documented
|
||||||
|
;; in the riverguile.1 manual page.
|
||||||
|
|
||||||
|
(define-module (riverguile)
|
||||||
|
#:export (R
|
||||||
|
R:input
|
||||||
|
R:map
|
||||||
|
R:keyboard-group))
|
||||||
|
|
||||||
|
(define (stringify x)
|
||||||
|
(cond ((string? x) x)
|
||||||
|
((number? x) (number->string x))
|
||||||
|
((symbol? x) (symbol->string x))))
|
||||||
|
|
||||||
|
(define-syntax R
|
||||||
|
(syntax-rules ()
|
||||||
|
((R arg ...)
|
||||||
|
(apply riverctl
|
||||||
|
(map stringify `(arg ...))))))
|
||||||
|
|
||||||
|
(define-syntax R:map
|
||||||
|
(syntax-rules ()
|
||||||
|
((R:map mode (mod key cmd ...) ...)
|
||||||
|
(for-each (lambda (args)
|
||||||
|
(apply riverctl
|
||||||
|
(map stringify
|
||||||
|
(append `(map mode) args))))
|
||||||
|
`((mod key cmd ...) ...)))))
|
||||||
|
|
||||||
|
(define-syntax R:input
|
||||||
|
(syntax-rules ()
|
||||||
|
((R:input name (val var ...) ...)
|
||||||
|
(for-each (lambda (args)
|
||||||
|
(apply riverctl
|
||||||
|
(map stringify
|
||||||
|
(append `(input name) args))))
|
||||||
|
`((val var ...) ...)))))
|
||||||
|
|
||||||
|
(define-syntax R:keyboard-group
|
||||||
|
(syntax-rules ()
|
||||||
|
((R:keyboard-group name . devices)
|
||||||
|
(let ((N (stringify 'name))
|
||||||
|
(D (map stringify 'devices)))
|
||||||
|
(riverctl "keyboard-group-create" N)
|
||||||
|
(for-each (lambda (d)
|
||||||
|
(riverctl "keyboard-group-add" N d))
|
||||||
|
D)))))
|
||||||
|
|
||||||
Reference in New Issue
Block a user