Skip to content

Instantly share code, notes, and snippets.

@kai11
Last active September 7, 2022 12:47
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kai11/bb5c2fa03cb21884bfcb76c01d1632c9 to your computer and use it in GitHub Desktop.
Save kai11/bb5c2fa03cb21884bfcb76c01d1632c9 to your computer and use it in GitHub Desktop.
Spacemacs on Ubuntu 16.04 - automatically switch between English and Russian layouts on entering and exiting insert state
;; Spacemacs on Ubuntu 16.04 - automatically switch between English and Russian layouts on entering and exiting insert state
;; "r" command will use English though
;; Idea from https://github.com/syl20bnr/spacemacs/issues/3225
;; exit hook below assumes your langunage #0 (first in Input Sources list) is English
;; if it's not, change 0 to index of English
(defun dotspacemacs/user-config ()
(setq prev_lang (substring (shell-command-to-string
"gsettings get org.gnome.desktop.input-sources current")
7 -1))
(add-hook 'evil-insert-state-entry-hook
(lambda ()
(shell-command (concat
"/usr/bin/gsettings set org.gnome.desktop.input-sources current " prev_lang)
)
)
)
(add-hook 'evil-insert-state-exit-hook
(lambda ()
(setq prev_lang (substring (shell-command-to-string
"gsettings get org.gnome.desktop.input-sources current")
7 -1))
(shell-command (concat
"/usr/bin/gsettings set org.gnome.desktop.input-sources current 0")
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment