How to add keyboard shortcut to toggle F1, F2, etc. as standard function keys?
In order to assign a keyboard shortcut to this script, you could create a service in Automator.



You must change Service receivesto no input. Then add Execute AppleScript and paste your script. Save it on ~/Library/Services.



Once saved, you must go to System Preferences → Keyboard → Shortcuts and you can find out under Services → General. Assign your preferred shortcut there.