Home Forums Software InstaDMG More PlistBuddy localization help requested

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #378116
    blake
    Participant

    Ok I have read through the two recent threads on modifying the ~/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist and ran into some issues on the non-roman localizations. First off thanks to the other posters and sharing their work!

    It turns out that the roman languages are fairly simple to configure the com.apple.HIToolbox.$UUID.plist for. But what we need to do is edit this preference file to provide the exact same options in the Input menu that users would see if they configured the system for Japanese, Korean, Chinese Traditional & Chinese Simplified. These localizations show multiple input methods in the menu and this is what I’m having a hard time getting PlistBuddy to replicate.

    Here are the desired xml entries that I want.
    [code]
    AppleEnabledInputSources


    InputSourceKind
    Keyboard Layout
    KeyboardLayout ID
    0
    KeyboardLayout Name
    U.S.


    Bundle ID
    com.apple.inputmethod.Kotoeri
    Input Mode
    com.apple.inputmethod.Japanese
    InputSourceKind
    Input Mode


    Bundle ID
    com.apple.inputmethod.Kotoeri
    Input Mode
    com.apple.inputmethod.Japanese.placename
    InputSourceKind
    Input Mode

    Four additional dict entries removed to shorten the post but I will need to configure those as well.
    [/code]

    The syntax I put together based on the previous threads looks like this.
    [code]
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:1 dict ” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:1:\”Bundle ID\” string com.apple.inputmethod.Kotoeri” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:1:\”Input Mode\” string com.apple.inputmethod.Japanese” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:1:\”InputSourceKind\” string Input Mode” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist

    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:2 dict ” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:2:\”Bundle ID\” string com.apple.inputmethod.Kotoeri” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:2:\”Input Mode\” string com.apple.inputmethod.Japanese.placename” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:2:\”InputSourceKind\” string Input Mode” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    [/code]

    This code mostly works however I get some extra keys that include the index number that I don’t want and suspect keep this from working.
    [code]
    AppleEnabledInputSources

    1

    Bundle ID
    com.apple.inputmethod.Kotoeri
    Input Mode
    com.apple.inputmethod.Japanese
    InputSourceKind
    Input Mode

    2

    Bundle ID
    com.apple.inputmethod.Kotoeri
    Input Mode
    com.apple.inputmethod.Japanese.placename
    InputSourceKind
    Input Mode

    3
    [/code]

    If anybody has some PlistBuddy syntax suggestions I suspect that’s my problem with editing this file.

    Thanks,
    blake

    Previous threads for reference..
    https://www.afp548.com/forum/viewtopic.php?showtopic=22278
    https://www.afp548.com/forum/viewtopic.php?showtopic=22427

    #378118
    larkost
    Participant

    Your problem is that you are creating a dictionary rather than an array a the root. But in this one case case I think it is actually easier to use “defaults”:

    [code]/usr/bin/defaults -currentHost write com.apple.HIToolbox AppleEnabledInputSources -array-add ‘{ InputSourceKind=”Keyboard Layout”; “KeyboardLayout ID”=0; “KeyboardLayout Name”=”U.S.”;}'[/code]

    I tend to go either with “defaults” or python, and skip PlistBuddy.

    #378120
    blake
    Participant

    Yes I considered using defaults with the old school syntax but decided to nut up and get a handle on PlistBuddy this time. You are correct that I had PlistBuddy setup to write into an array. In my process of isolating the commands I’m building they got separated from the ones that create the array. After putting things together it’s working as expected.

    If these commands run before the ones in my original post those commands work because the array get’s created.
    [code]
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources array” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:0 dict ” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:0:\”InputSourceKind\” string Keyboard Layout” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:0:\”KeyboardLayout ID\” integer 0″ /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    /usr/libexec/PlistBuddy -c “Add AppleEnabledInputSources:0:\”KeyboardLayout Name\” string U.S.” /Users/user/Library/Preferences/ByHost/com.apple.HIToolbox.$UUID.plist
    [/code]

    Thanks for the defaults example Karl!

    #378166
    thomasb
    Participant

    Why script this when you can make Mac OS X do all the work of creating those xml plist files for you? All you have to do then, is to create a package of those plist files and put that into your InstaDMG build train.

    #378168
    blake
    Participant

    The images I’m building are used for software testing. They boot up and run a script on first boot. This script allows the image to be localized in 13 languages or to run Apple setup depending on the testers need. The image itself does not have any home folders at all until this script runs and creates them.

    Additionally I do not like putting any files into our images. It’s much cleaner to modify the ones the OS creates as it boots up. You can immagine putting a bunch of 10.5.x preferences into a 10.6.x image. 95% of the time it would work without issue. But that other 5% I have the angry mob at my door blaming me for making a bad image. After a few years of making images from apple pre-release os builds you get very conservative with the process.

    The up side is we dont have any non-Apple OS X software in our testing images. At least I get to avoid that mess 🙂

    Blake

    #378172
    thomasb
    Participant

    I see.

    Regarding compatability, you still need to look at the files 10.5.x and 10.6.x create to be able to script them correctly. A script made for 10.5.x wont necessarily work for 10.6.x 🙂

    I always compare preferences files created by the current OS version with the the ones I have in my package installers. If there are any differences, I make sure to update the package installers with the most recent files created by the OS. That way I avoid any scripting errors or compatability issues.

    The ideal thing would maybe be to be able to make your own Setup Assistant, simliar to Apple’s MacBuddy, where the user can choose i.e. language and keyboard layout the first time they start their custom installed Mac.

    #378178
    blake
    Participant

    We collect input from the user about what localization the want before restoring the disk. This information is stored in nvram and durring firstboot the script customizes the system. People like to kick the process off and not come back until it’s fully done.

    The ideal solution would be a .plist configuration file that we could feed to apple setup. That way after the restore is done you could just write a configuration file to disk and let apple setup handle all the details. Hmm no I didn’t just wish for sysprep on mac os x 😈 😈

    Blake

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Comments are closed