Yes red is switched 12v, black ground and green is your dimmer for when headlights are on.
You can tap the headlight wiring loom where it connects into the back of the headlamp assembly.