Ich habe das Problem, dass das type4me blafasel-Skript aktuell nur richtig mit der deutschen und englischen Tastatur-Belegung funktioniert. Bei der Schweizer Tastatur, die der Französischen ähnlich ist, müsste ein andere Code ausgeführt werden, wenn Umlaute eingefügt werden sollen. Deshalb suchte ich nach einem Weg die aktuelle Tastatur-Belegung (dt, en, fr usw.) via AppleScript auszulesen und das brachte mich dann über einige Tips auf diesen Seiten:
Aktuelles Tastatur via AppleScript Layout auslesen
Tja, und hier das Resultat:
current_keyboard_layout()
on current_keyboard_layout()
set myversion to do shell script "sw_vers -productVersion"
if myversion ≥ "10.5.5" then
set pListPath to do shell script "ls ~/Library/Preferences/ByHost/com.apple.HIToolbox." & macs_UUID() & ".plist"
else
set pListPath to do shell script "ls ~/Library/Preferences/ByHost/com.apple.HIToolbox." & macs_MAC() & ".plist"
end if
tell application "System Events"
set pList to property list file pListPath
set a to property list items of property list item "AppleSelectedInputSources" of contents of pList
set theList to {}
set dialogText to "enabled keyboard layouts:" & return & return
repeat with i in a
set v to value of i
if |InputSourceKind| of v is "Keyboard Layout" then
set end of theList to v
return |KeyboardLayout Name| of v
end if
end repeat
end tell
end current_keyboard_layout
on macs_UUID()
set a to (do shell script "ioreg -rd1 -c IOPlatformExpertDevice | grep -E '(UUID)'")
set AppleScript's text item delimiters to "\""
set b to text item -2 of a
set AppleScript's text item delimiters to ""
return b
end macs_UUID
on macs_MAC()
set myMACaddress to (do shell script "ifconfig en0 ether | grep -i ether" as string) as string
set AppleScript's text item delimiters to " "
set b to every text item of myMACaddress
set AppleScript's text item delimiters to ""
repeat with k in b
if k contains ":" then
set AppleScript's text item delimiters to ":"
set myMAC to every text item of k
set AppleScript's text item delimiters to ""
return myMAC as text
exit repeat
end if
end repeat
end macs_MAC