MacBooks have a row of dual function keys at the top of the keyboard (F1-12, doing double duty as louder/softer, brighter/dimmer, etc). You can change their "normal" behavior from one to the other via the System Preferences > Keyboard & Mouse > "Use all F1, F2, etc. keys as standard function keys" checkbox.
What I want is an icon I can put on my dock and click to toggle this preference. At first, you'd think that this shell script like this would do it:
#!/bin/bash
curState=`defaults read "Apple Global Domain" com.apple.keyboard.fnState`
if [ $curState = "1" ]; then
defaults write "Apple Global Domain" com.apple.keyboard.fnState 0
fi
{etc.}
... because it toggles the actual bit that is toggled by the checkbox in System Preferences. Unfortunately, it looks like the OS doesn't notice the change (when done this way) until you reboot. All the online discussion of this I could find typically ends at
exactly this point.
So: I'm not picky about methods. If there's a way to force a re-load of the preferences from the command line, that's great. If there's a good Apple-scripty way to do it that's not crazy slow (e.g., bouncing script icon on dock, script load, bouncing system prefs icon, system prefs window open for 1ms, exit -- I already wrote that script), that'd be cool too. Does Quicksilver have a hook into this pref? That'd be great.
posted by bcwinters at 10:01 AM on September 5, 2008