Control USB power by USB power
You could use a 5V relay module like this one. Your design will have the following connections:




DC+ to USB 5V
DC- to USB 0V
IN1 to USB 5V
NO to your raspberry pi 5V in
COM to the 5V raspberry pi wall wort/plug socket power supply
NC disconnected


N.b The wall wort power supply's ground also needs connected to the raspberry pi. This can be connected directly (not through the relay) and does not have to be connected to the relay DC-