I am currently learning the Dvorak keyboard at the moment so I need to change keyboard when I am not in the training application 'Type Fu'.

What I want to do is:  
1) Have the `Dvorak - QWERTY ⌘` when I am in the 'Type Fu' application  
2) Change to the `QWERTY` keyboard when I am in any other application  

Later on when I have learnt it, I would like this to happen:  
1) Have the `Dvorak - QUERTY ⌘` keyboard for all applications apart from developer environments such as `Xcode` and `Terminal`  
2) Automatically switch to `Programmer Dvorak` when I am in developer environments such as `Xcode` and `Terminal`

I know that the second option I want is similar to the first, however it has more exceptions.  
  
Is it posible to do this in any way (even by downloading third party software)? This would make it so much easier when I am learning the new layout and when I change from programming environments to non-programming environments.

I know other questurns like this have been asked before, however, (https://apple.stackexchange.com/questions/222844/automatically-change-keyboard-layout-based-on-app-focus) does not have an answer (or any comments) and (https://apple.stackexchange.com/questions/28393/auto-change-keyboard-layout-based-on-application-focus) does not change per application, only per document. This means if I were to create more tabs in my enviroments, it may or may not switch to the correct one.