-- © hubionmac.com 7.10.2008
-- aktuelles keyboard layout ab OSX 10.5.5
-- Seit dieser Version hat Apple von mac-adresse auf uuid umgestellt (Preferences by Host und Time-Machine, glaube ich....
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
4 Comments
Hallo,
interessant - allumfassend funktionierend scheint es aber leider nicht zu sein.
Gerade unter 10.6.2 getestet und erhalte den folgenden Fehler
error "ls: /Users/fidel/Library/Preferences/ByHost/com.apple.HIToolbox.00000000-0000-1000-8000-0017F2040476.plist: No such file or directory" number 1
Gruss
fidel
Hm, bei mir geht es... hast Du denn eine HIToolbox plist in dem Ordner?
Schalte doch sonst mal eine weite Sprache im Tastaturlayout dazu... hm... oder habe ich das bei der Migration von 10.5 mitgenommen...?
Bei mit läuft es nämlich unter 10.6.2
Also Zwischeninfo:
Work-Mac mit 10.6.2 - hochgezogen von 10.5 -> Script funktionert.
Egal ob eine oder mehrere Sprachen konfiguriert sind.
Der Mac zuhause - siehe Kommentar 1 - ist komplett neu aufgesetzt - werde ich dann später mal gegenchecken wie die Lage dort aussieht bzgl plist.
Gruss
fidel
Ok - es sieht so aus als ob auf meiner cleanen 10.6 Install nach einer falschen Datei innerhalb den Preferences gesucht wird.
Screenshot:
https://dl.getdropbox.com/u/223435/public_trash/20091211_161559_ss.jpg
Hoffe die Info hilft dir weiter ;)
Gruss
fidel