Use Caps Lock to switch to and from languages on Sierra
To switch keyboard layout with caps-lock key you need to
remap caps-lock to F18 with command (in Terminal.app):

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000006D}]}'


Then, go to System Preferences/Keyboard/Shortcuts/Input Sources, use key 'caps lock' to switch input source.

No additional software is required on mac os Sierra.

To keep this working after you logout do the following:
create file ~/bin/caps2f18.sh with the following content:

hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x70000006D}]}' &gt; /dev/null 2&gt;&amp;1


Make it executable:

chmod +x ~/bin/caps2f18.sh


Create file ~/Library/LaunchAgents/com.user.loginscript.plist with the following content:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
   &lt;key&gt;Label&lt;/key&gt;
   &lt;string&gt;com.user.loginscript&lt;/string&gt;
   &lt;key&gt;ProgramArguments&lt;/key&gt;
   &lt;array&gt;
        &lt;string&gt;zsh&lt;/string&gt;
        &lt;string&gt;-c&lt;/string&gt;
        &lt;string&gt;~/bin/caps2f18.sh&lt;/string&gt;
   &lt;/array&gt;
   &lt;key&gt;RunAtLoad&lt;/key&gt;
   &lt;true/&gt;
   &lt;key&gt;ThrottleInterval&lt;/key&gt;
   &lt;integer&gt;86400&lt;/integer&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Execute

launchctl load ~/Library/LaunchAgents/com.user.loginscript.plist


logout login, or execute launchctl start com.user.loginscript