AtlatestRepositorysigil-wm
1
(import (sigil async)2
(sigil wm host)3
(sigil wm input))5
(define host (start-host!))6
(define stage 'configure)7
(define control? #f)8
(define greek? #f)9
(define last-token #f)11
(set-key-hook! host12
(lambda (event)13
(when (= (input-event-state event) 1)14
(case (input-event-code event)15
((58)16
(unless (equal? (input-event-keysyms event) '(65507))17
(error "Caps-as-Control option was not applied"))18
(set! control? #t))19
((35)20
(unless (and (equal? (input-event-first-layout-keysyms event) '(104))21
(pair? (input-event-keysyms event))22
(not (equal? (input-event-keysyms event) '(104)))23
(equal? (input-event-keysyms event) (input-event-base-keysyms event)))24
(error "active/base/first-layout symbols were not preserved"))25
(set! greek? #t))))26
(forward event)))28
(on-event! host29
(lambda (event)30
(case (event-type event)31
((ready)32
(configure-keyboard! host 1 "us,gr" 1000 10000 options: "ctrl:nocaps"))33
((keyboard-state)34
(case stage35
((configure)36
(unless (= (event-ref event groups:) 2)37
(error "configured keyboard lacks two groups"))38
(set! stage 'control)39
(emulate-key! host 1 58 #t)40
(set! last-token (emulate-key! host 1 58 #f)))41
((group)42
(unless (= (event-ref event group:) 1)43
(error "explicit group selection failed"))44
(set! stage 'greek)45
(emulate-key! host 1 35 #t)46
(set! last-token (emulate-key! host 1 35 #f)))))47
((input-completed)48
(when (and last-token (= (event-ref event id:) last-token))49
(case stage50
((control)51
(set! stage 'group)52
(set-keyboard-group! host 1 1))53
((greek) (stop-host! host))))))))55
(with-async (run-host! host))56
(unless (and control? greek? (= (host-statistic host 2) 0))57
(error "keyboard configuration cycle incomplete"))58
(display "KEY_CONFIG=PASS options groups base and first-layout symbols\n")