summaryrefslogtreecommitdiff
path: root/main.scm
blob: a591764145a1587ad889b92d79a8c3d7d0f125e2 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
(use-modules (srfi srfi-9)
             (wm))

(define-record-type <wm-config>
  (make-config
   inner-border-width
   outer-border-width
   magnet-border-width
   offset-x
   offset-y
   offset-width
   offset-height)
  wm-config?
  (inner-border-width   config-inner-border-width  set-config-inner-border-width!)
  (outer-border-width   config-outer-border-width  set-config-outer-border-width!)
  (magnet-border-width  config-magnet-border-width set-config-magnet-border-width!)
  (offset-x             config-offset-x            set-config-offset-x!)
  (offset-y             config-offset-y            set-config-offset-y!)
  (offset-width         config-offset-width        set-config-offset-width!)
  (offset-height        config-offset-height       set-config-offset-height!))

(define config
  (make-config
   2    ; inner-border-width
   0    ; outer-border-width
   16   ; magnet-border-width
   0    ; offset-x
   0    ; offset-y
   0    ; offset-width
   0    ; offset-height
   ))

(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))
     (newline)))
  (wm-run)
  (wm-quit))