Toggle "Use all F1, F2 as standard keys" via script I toggle the "Use all F1, F2 as standard keys" setting very often and would like to automate it via a script (or a keyboard shortcut). Is it possible? I've tried to Google the right arguments for defaults write ... but unsuccessfully.





Update: I ended up creating https://github.com/jkbrzt/macos-fn-toggle based of the answers here.

Update II: There's now also — https://github.com/Pyroh/Fluor — a really nice menubar app that allows you to automatically change the behaviour of the keyboard's fn keys depending on the active application.
tell application "System Preferences"
    reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"


You could also use defaults write -g com.apple.keyboard.fnState -bool true, but I don't know any way to apply the changes without logging out and back in again.