Last active
September 7, 2022 12:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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