dotfiles/oni/kbd.scm

29 lines
649 B
Scheme

(define-module (oni kbd)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:export (kbd))
(define (convert-modifier mod)
(match mod
("C" "Ctrl")
("M" "Mod1")
("S" "Shift")
("s" "Mod4")))
(define (convert-key key)
(match key
("RET" "Return")
("SPC" "space")
("<backspace>" "BackSpace")
(_ key)))
(define (kbd str)
(let ((parts (string-split str #\-)))
(string-join
(fold-right (λ (key previous)
(if (null? previous)
(list (convert-key key))
(cons (convert-modifier key) previous)))
'() parts)
"-")))