Skip to content

Instantly share code, notes, and snippets.

@LinArcX
Created January 21, 2022 17:37
Show Gist options
  • Save LinArcX/69052ae7f5b1a8e70ae5872084c2d94d to your computer and use it in GitHub Desktop.
Save LinArcX/69052ae7f5b1a8e70ae5872084c2d94d to your computer and use it in GitHub Desktop.
;; async-run function
(defparameter *async-shell* (uiop:launch-program "bash" :input :stream :output :stream))
(defun async-run (command)
(write-line command (uiop:process-info-input *async-shell*))
(force-output (uiop:process-info-input *async-shell*))
(let* ((output-string (read-line (uiop:process-info-output *async-shell*)))
(stream (uiop:process-info-output *async-shell*)))
(if (listen stream)
(loop while (listen stream)
do (setf output-string (concatenate 'string
output-string
'(#\Newline)
(read-line stream)))))
output-string))
;; my keyboard layout function
(defun linarcx-keyboard-layout (ml)
(declare (ignore ml))
(let ((cmd "xkb-switch -p"))
(string-trim '(#\Newline) (async-run cmd))))
(add-screen-mode-line-formatter #\L #'linarcx-keyboard-layout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment