Monday, October 25, 2010

Change default keyboard layout for loginwindow

We discovered that a system restore image we used to deploy new Macs with had the wrong keyboard layout at the loginwindow. If you change the keyboard layout in the Accounts PrefPane, it just affects the currently logged in user.
Apples solution to this is either to reinstall Mac OS X or select to show the input menu in the loginwindow, this is two solutions that I can't accept, so I started digging and found a solution!

The settings are stored in /Library/Preferences/com.apple.HIToolbox.plist and changing these solved my problem.

Here is quick and dirty script to change the default keyboard layout to Swedish:


#!/bin/bash

# This will set default keyboard language to Swedish.

# Path to plist file
PLISTDOMAIN="/Library/Preferences/com.apple.HIToolbox.plist"

# Path to PlistBuddy
PB="/usr/libexec/PlistBuddy"

"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleCurrentKeyboardLayoutInputSourceID com.apple.keylayout.Swedish-Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"

exit 0

Tuesday, October 19, 2010

Create mobile account for two different users with the same name fails

We discovered this today, and we haven't found any information about it anywhere, so...

If you have a mac bound to an Active Directory where there are users with the same name but different usernames, you may see that certain users cannot login to the mac. This happens when you have "Create mobile account at login" activated and a user tries to login who has the same name as a previously logged in user.

What is going wrong then? I don't know exactly, besides that it's the "RecordName" key that is the problem. There cannot be two users in the local database that has a value in RecordName matching any other user's value in RecordName.

If you change the value to something else on the first user, the second user can login.

Delete the value:
sudo dscl . delete /Users/uname1 RecordName "John Doe"

Append a new value:
sudo dscl . append /Users/uname1 RecordName "John Marc Doe"

Or simply change:
sudo dscl . change /Users/uname1 RecordName "John Doe" "John Marc Doe"

UPDATE 2010-10-20
I made a bugreport to Apple regarding this yesterday and got a response that they need logs. I will upload the logs today to Apple and then we'll see what they have to say about it...

UPDATE 2010-10-25
Apple says this is expected behavior. I have replied that I disagree.

Wednesday, September 22, 2010

Convert movies to iPhone friendly format with ffmpeg on a Mac

I wanted to make a bash script that parsed a given directory for movie files and then made them into an iPhone friendly format. In this script I use HandBrakeCLI and ffmpeg.

HandBrakeCLI is a no-brainer to install, just download the binary and run it, but ffmpeg is a bit harder to get working, so here are a brief and "technical" instruction on how I succeeded. Apple Developer Tools is required!

1. mkdir ~/source
2. cd ~/source

3. cvs -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame login (press enter when asked for passwd)
4. cvs -z3 -d:pserver:anonymous@lame.cvs.sourceforge.net:/cvsroot/lame co -P lame
5. cd lame
6. ./configure
7. make
8. sudo make install

9. cd ~/source
10. cvs -d:pserver:anonymous@faac.cvs.sourceforge.net:/cvsroot/faac login
11. cvs -z3 -d:pserver:anonymous@faac.cvs.sourceforge.net:/cvsroot/faac co -P faac
12. cd faac
13. ./configure
14. make
15. sudo make install

16. cd ~/source
17. svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
18. cd ffmpeg
19. ./configure --enable-libmp3lame --enable-shared --disable-mmx --arch=x86_64 --enable-libfaac --enable-gpl --enable-nonfree --enable-avfilter --enable-postproc
20. make
21. sudo make install


And now, when you're done, you can convert movies to mp4 that is 480px wide and keeping the aspect ratio. This is what I use, found bits here and there and put it together to this:

ffmpeg -i INPUT.avi -acodec libfaac -ac 2 -vcodec mpeg4 -vf "scale=480:-1" -b 1000k -ab 128k -coder 1 -flags +aic+cbp+loop+mv4+naq -trellis 1 OUTPUT.mp4

I'm using ffmpeg SVN-r25157, Lame 3.98.4 and faac 1.28 on Mac OS X 10.6.4. If you download and compile the standard ffmpeg 0.6, the "-vf "scale=480:-1" bit will not work. So download the latest through cvs.

This is more or less a rip off of the instruction at stephenjungels.com. In the latest svn of ffmpeg, there is no support for faad, so I left that bit out.

This instruction is available "as is". I will not answer any questions about "How do I do this and that?"

Friday, August 20, 2010

If Boot Camp drivers fails to install

Had this problem yesterday with a new iMac (iMac10,1).

I had an old Windows XP SP3 image with all the applications etc I wanted in Windows. I applied the image to a Boot Camp partition, booted Windows without any problems.

Now I wanted to install the Boot Camp drivers from the Snow Leopard DVD, I launched the installation, but it failed immediately with a message saying something like "a problem occurred, please try again later".

The event log said "msiinstaller error code 11708", which gave me nothing.
Then I launched the BootCamp.msi (in /Boot Camp/Drivers/Apple) with "msiexec /i BootCamp.msi /l* c:\bc.log". In the log file I found that a function called GETINTELGRXID failed with exit code 3.
I think this is supposed to get which kind of Intel graphics card it is in the machine, but since it's an Nvidia card in this iMac I thought it didn't matter if that function ran or not.

So next thing to do was editing the msi with Orca and delete all entries that contained "GETINTELGRXID" (I think I found it in two places). When that was done, I just saved the msi and launched it with the command above, and it worked! Now I have an iMac that have a fully working Boot Camp install!