sketchybar: init
This commit is contained in:
parent
ded82a8f8b
commit
ae71080920
10 changed files with 182 additions and 96 deletions
29
stow/.config/sketchybar/plugins/input-method.sh
Executable file
29
stow/.config/sketchybar/plugins/input-method.sh
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
|
||||
# from: https://apple.stackexchange.com/questions/251666/how-to-get-current-input-language-of-the-input-source
|
||||
|
||||
#!/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="Australian"
|
||||
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
|
||||
LABEL="English"
|
||||
ICON="🇬🇧"
|
||||
elif [ "$EASTERN_LANGUAGE" = "$HIRIGANA" ]; then
|
||||
LABEL="Japanese"
|
||||
ICON="🇯🇵"
|
||||
elif [ "$EASTERN_LANGUAGE" = "$KATANA" ]; then
|
||||
LABEL="Katakana"
|
||||
ICON="🈴"
|
||||
fi
|
||||
|
||||
sketchybar --set "$NAME" label="$LABEL" icon="$ICON"
|
||||
Loading…
Add table
Add a link
Reference in a new issue