Skip to content

Instantly share code, notes, and snippets.

@kai11 kai11/.spacemacs
Last active Mar 26, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.