Windows:

To swap capslock for esc on windows you have to change the registries

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,01,00,01,00,3a,00,00,00,00,00

Copy this code into a .reg file and execute it. Alternatively, you can manually add it to the registries with regedit.

Linux:

Run the following command:

setxkbmap -option caps:swapescape

Note: To run it automatically at start, add the command to ~/.xinitrc