marionette: Fix typing of capital letters.

Previously we'd use "sendkey P" instead of "sendkey shift-p", which had
no effect.

* gnu/build/marionette.scm (character->keystroke): New procedure.
(string->keystroke-commands): Use it.
This commit is contained in:
Ludovic Courtès 2017-08-27 22:00:19 +02:00
parent 8bd5231485
commit 0a80981178
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -264,6 +264,14 @@ (define %qwerty-us-keystrokes
(#\bs . "backspace")
(#\tab . "tab")))
(define (character->keystroke chr keystrokes)
"Return the keystroke for CHR according to the keyboard layout defined by
KEYSTROKES."
(if (char-set-contains? char-set:upper-case chr)
(string-append "shift-" (string (char-downcase chr)))
(or (assoc-ref keystrokes chr)
(string chr))))
(define* (string->keystroke-commands str
#:optional
(keystrokes
@ -272,9 +280,9 @@ (define* (string->keystroke-commands str
to STR. KEYSTROKES is an alist specifying a mapping from characters to
keystrokes."
(string-fold-right (lambda (chr result)
(cons (string-append "sendkey "
(or (assoc-ref keystrokes chr)
(string chr)))
(cons (string-append
"sendkey "
(character->keystroke chr keystrokes))
result))
'()
str))