summaryrefslogtreecommitdiff
path: root/main.scm
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2022-12-08 18:25:18 +0100
committerSamuel Fadel <samuel@nihil.ws>2022-12-08 18:25:18 +0100
commit6f54084c0ee63f4b341f8f92efbc8b82d3dfa224 (patch)
tree454e8d7cf51aa4cded69535d60ec56a753325034 /main.scm
parent6bdaee03c0fd3caac390dffdaaf52d54653b1430 (diff)
Working example with keybindings done from Scheme.
* main.scm: Added utility and keybinding calls * wm.scm: Added necessary bindings to C code * schewm.c: Some utility functions for grabbing keys
Diffstat (limited to 'main.scm')
-rw-r--r--main.scm30
1 files changed, 24 insertions, 6 deletions
diff --git a/main.scm b/main.scm
index 6487a30..a591764 100644
--- a/main.scm
+++ b/main.scm
@@ -5,7 +5,7 @@
(make-config
inner-border-width
outer-border-width
- manger-border-width
+ magnet-border-width
offset-x
offset-y
offset-width
@@ -30,16 +30,34 @@
0 ; offset-height
))
-(define keys
- '(((make-key-chord (key-from-str "q")) . wm-quit)))
+(define (make-key key)
+ (list #f (key-from-str key)))
+
+(define (make-shift-key key)
+ (list #t (key-from-str key)))
+
+(define wm-keybindings
+ `((,(make-shift-key "q") . ,wm-quit)
+ (,(make-key "Tab") . ,wm-focus-next)))
+
+(define (grab-keys keybindings)
+ (unless (null? keybindings)
+ (let* ((keybinding (car keybindings))
+ (chord (car keybinding))
+ (func (cdr keybinding))
+ (with-shift (car chord))
+ (key (car (cdr chord))))
+ (if with-shift
+ (wm-grab-key-with-mod-shift key)
+ (wm-grab-key-with-mod key))
+ (grab-keys (cdr keybindings)))))
(when (wm-init)
+ (grab-keys wm-keybindings)
(wm-set-key-press-handler!
(lambda (mod keysym)
(display (list mod keysym))
- (display "\n")))
- (display config)
- (display "\n")
+ (newline)))
(wm-run)
(wm-quit))