Skip to content

Instantly share code, notes, and snippets.

@tamphh
Created July 4, 2019 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamphh/f68a574588b810349ee6bcdf9e970141 to your computer and use it in GitHub Desktop.
Save tamphh/f68a574588b810349ee6bcdf9e970141 to your computer and use it in GitHub Desktop.
Bash script to get input source (keyboard name) fo OS X
#!/bin/bash
input_name=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name' | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
if [[ -z "$input_name" ]]; then
echo "V.N"
elif [[ -n "$input_name" ]]; then
echo "U.S"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment