summary refs log tree commit diff stats
path: root/bin/acdwm.scm
blob: cfa5983fff482aadec3a5d17b5d2913a7573211f (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
#!/bin/sh
#| -*- scheme -*-
exec csi -s "$0" "$@"                  ; acdwm
|#

(import (chicken condition)
        (acdwm util)
        (acdwm xlib)
        (acdwm keys)
        (acdwm events))

;;; Configuration
;; TODO: this should go in its own file
(bind "M-<F1>" (lambda (ev dpy)
                 (let ((win (xevent-xkey-subwindow ev)))
                   (when (some? win)
                     (xraisewindow dpy win)))))
(bind "M-b1" (lambda (ev dpy)
               (xraisewindow dpy (xevent-xbutton-subwindow ev))
               (initialize-drag 'move ev)))
(bind "M-b3" (lambda (ev dpy)
               (xraisewindow dpy (xevent-xbutton-subwindow ev))
               (initialize-drag 'resize ev)))

;;; Main entry point

(define (acdwm-setup)
  (or (get-display)
      (error "Can't capture display"))
  (grab-input))

(define (acdwm-cleanup)
  (dprint "Cleaning up"))

(define (main args)
  (parameterize ((DEBUG #t))
    (dprint "acdwm: starting up")
    (dynamic-wind acdwm-setup
                  (lambda ()
                    (call/cc
                     (lambda (k)
                       (with-exception-handler
                           (lambda (exn)
                             (xclosedisplay (get-display))
                             (k exn))
                         handle-events))))
                  acdwm-cleanup))
  (xclosedisplay (get-display))
  (exit))

(cond-expand
  ((or chicken-script compiling)
   (import (chicken process-context))
   (main (command-line-arguments)))
  (else))