Skip to content

Instantly share code, notes, and snippets.

@ahungry
Created June 2, 2016 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahungry/d8be8dca688aae05824ddee4122e90cd to your computer and use it in GitHub Desktop.
Save ahungry/d8be8dca688aae05824ddee4122e90cd to your computer and use it in GitHub Desktop.
send in special unicode chars np
(defcommand wss (string) ()
"Send a string of characters, including non-ascii ones (needs work for more than 1 char at a time)"
(map nil (lambda (ch)
(let* ((char-code (char-code ch))
(keysym (+ char-code (if (>= char-code #x100) #x01000000 0)))) ;; Only applicable if code >= #x100
(xlib:change-keyboard-mapping
*display*
(make-array '(1 1) :initial-element keysym)
;;#2A(
;;#(16778171) ;; λ in slot 8
;;#(16777618) ;; ƒ in slot 9
;; )
:first-keycode 8) ;; todo - check for first free keycode that doesn't have a keysym vs assuming its #8
(xtest:fake-key-event *display* 8 t :delay 0)
(xtest:fake-key-event *display* 8 nil :delay 1))) string))
(defcommand xdo-lambda () ()
(wss "λ"))
;;(run-shell-command "xdotool type λ"))
(defcommand xdo-fn () ()
(wss "ƒ"))
;;(run-shell-command "xdotool type ƒ"))
(defcommand xdo-alpha () ()
(wss "α"))
;;(run-shell-command "xdotool type α"))
(defcommand xdo-arrow () ()
(wss "→"))
;;(run-shell-command "xdotool type →"))
(defcommand xdo-psi () ()
(wss "ψ"))
;;(run-shell-command "xdotool type ψ"))
(defcommand xdo-plus-minus () ()
(wss "±"))
;;(run-shell-command "xdotool type ±"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment