Skip to content

Commit

Permalink
Add language detection because god dammit Swedish!
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzaadi committed Jun 19, 2017
1 parent 7112df5 commit b2b3cfd
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
36 changes: 36 additions & 0 deletions bin-mac/apple-language
@@ -0,0 +1,36 @@
#!/usr/bin/env osascript
# Example call.
#set activeKbdLayout to my getActiveKeyboardLayout() # ->, e.g., "U.S."

on getActiveKeyboardLayout()

# Surprisingly, using POSIX-style paths (even with '~') works with
# the `property list file` type.
set plistPath to "~/Library/Preferences/com.apple.HIToolbox.plist"

# !! First, ensure that the plist cache is flushed and that the
# !! *.plist file contains the current value; simply executing
# !! `default read` against the file - even with a dummy
# !! key - does that.
try
do shell script "defaults read " & plistPath & " dummy"
end try

tell application "System Events"

repeat with pli in property list items of ¬
property list item "AppleSelectedInputSources" of ¬
property list file plistPath
# Look for (first) entry with key "KeyboardLayout Name" and return
# its value.
# Note: Not all entries may have a 'KeyboardLayout Name' key,
# so we must ignore errors.
try
return value of property list item "KeyboardLayout Name" of pli
end try
end repeat

end tell
end getActiveKeyboardLayout
set currentLanguage to getActiveKeyboardLayout()
do shell script "echo " & quoted form of currentLanguage
18 changes: 18 additions & 0 deletions bin-mac/apple-language-to-emoji
@@ -0,0 +1,18 @@
#!/bin/bash
CURRENT_LANGUAGE=`apple-language`
SWEDEN="🇸🇪"
ISRAEL="🇮🇱"
US="🇺🇸"


case ${CURRENT_LANGUAGE} in
ABC)
echo ${US}
;;
Swedish)
echo ${SWEDEN}
;;
Hebrew)
echo ${ISRAEL}
;;
esac
2 changes: 1 addition & 1 deletion tmux/tmux.solarized.dark.conf
Expand Up @@ -24,6 +24,6 @@ setw -g window-status-activity-attr 'bold'
setw -g window-status-separator ''
setw -g window-status-bg 'colour0'
set -g status-left '#[fg=colour15,bg=colour14,bold] #S #[fg=colour14,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour0,bg=colour14,nobold,nounderscore,noitalics]'
set -g status-right '#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour10,bg=colour0] #{prefix_highlight}#[fg=colour11,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] #(itunes-tmux.sh || echo "") %a %b %d 🕐 %R #(battery) #(wifi) #(docker-status-check.sh)#[fg=colour14,bg=colour11,nobold,nounderscore,noitalics]#[fg=colour15,bg=colour14] #(whoami)💻 #h '
set -g status-right '#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour10,bg=colour0] #{prefix_highlight}#[fg=colour11,bg=colour0,nobold,nounderscore,noitalics]#[fg=colour7,bg=colour11] #(itunes-tmux.sh || echo "") %a %b %d 🕐 %R #(battery) #(wifi) #(docker-status-check.sh)#[fg=colour14,bg=colour11,nobold,nounderscore,noitalics]#[fg=colour15,bg=colour14] #(apple-language-to-emoji) #(whoami)💻 #h '
setw -g window-status-format '#[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]#[default] #I:#W #[fg=colour0,bg=colour0,nobold,nounderscore,noitalics]'
setw -g window-status-current-format '#[fg=colour15,bold] #I:#W#[default]'

0 comments on commit b2b3cfd

Please sign in to comment.