step 1: caps lock -> control
http://blog.csdn.net/guxi123/article/details/50562402
$ sudo vim /etc/default/keyboard # modify: XKBOPTIONS="ctrl:nocaps"
$ sudo dpkg-reconfigure keyboard-configuration
now, caps lock is mapped to control (CONTROL_L), you can use xev to check it's key code.
step 2: control -> dual-role key
Install xcape, then config this:
xcape -e 'Control_L=Escape'
Now, your caps lock key is Escape pressed alone, and is Control when pressed with another key.
If you failed to install xcape, you may use c-[ as an alternative to escape.