How to get current input language of the input source
Solution 1:
One possible work-around is to configure the input source so that Caps Lock is used to switch to English. Then you can tell the IM is in that state by the green light on the keyboard (if it has one for capslock).
Solution 2:
I'm doing to go something similar, except with Japanese/ English.
I wrote the following script:
#!/usr/local/bin/bash
# Checks current keyboard input source (aka language)
#These are the strings that MacOS uses to identify the current input source
ENGLISH="U.S."
HIRIGANA="com.apple.inputmethod.Japanese"
KATANA="com.apple.inputmethod.Japanese.Katakana"
WESTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep 'KeyboardLayout Name' | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
# If the current language is not western one, then check a different variable
EASTERN_LANGUAGE=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | grep -w 'Input Mode' | head -1 | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
if [ $WESTERN_LANGUAGE == $ENGLISH ]
then
echo 🇬🇧
elif [ $EASTERN_LANGUAGE == $HIRIGANA ]
then
echo 🇯🇵
elif [ $EASTERN_LANGUAGE == $KATANA ]
then
echo 🈴
fi
This determines the current language and shows a relevant emoji. You can combine it with xbar (rebranded bitbar) and show the current language in the menu bar; you'll also want to have the script run after you change the language (you can prob use iCanHazShortcut to bind a keyboard shortcut to that).
A simpler way is to go into the Mac Keyboard settings and have it show an icon for the current input source (not sure how well that works if you're using a 3rd party input source).