I hardly ever use the function keys on my macbook pro. I mostly just use them for volume, brightness, etc. Now that I've started playing Starcraft 2 a bunch, I want to use them without having to press the fn key down.
I want to write a little shell script that will flip the "Use all F1, F2, etc keys as standard function keys" check box. I was thinking I could use the defaults command to change it but I wasn't sure what values to use. This way I don't have to change the the preferences every time I want to play. I can just run the script that'll switch the keys and even launch the game.
Any ideas?
If you're using a Mac, click the Apple menu, select System Preferences, and then click Keyboard. Check the box next to "Use F1, F2, etc keys as standard function keys," and then close the window.
On your Mac, choose Apple menu > System Preferences, click Keyboard , then click Keyboard. Select “Use F1, F2, etc. keys as standard function keys” or “Use F1, F2, etc. keys as standard function keys on external keyboards” (depending on your Mac model).
To enable FN Lock on the All in One Media Keyboard, press the FN key, and the Caps Lock key at the same time. To disable FN Lock, press the FN key, and the Caps Lock key at the same time again.
An AppleScript that should do the trick -- taken from http://scriptbuilders.net/files/fn1.1.html, with slight modifications
--Check if GUI Scripting is Enabled
tell application "System Events"
if not UI elements enabled then
set UI elements enabled to true
end if
end tell
--Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
tell application "System Events"
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
click checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
Tested on MacOS 10.6.4
The command is defaults write -g com.apple.keyboard.fnState
, although I've had problems in the past changing it. I ended up just using an AppleScript. Give it a try.
defaults write -g com.apple.keyboard.fnState -boolean true
Edit
To elaborate, the problems I've had is that the actual value is changed, but it doesn't actively change the setting in System Preferences nor does the fnState toggle, because the file is only read at boot/login etc. Also, making changes to a config file that's opened by another task sounds like a good way to corrupt the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With