DIY mains switches are not a good idea because the voltages involved are potentially lethal and it is easy to create a circuit that works, but exposes people and components to mains voltages. Your safest solution would be to use something like the PowerSwitch Tail, which is designed to solve this problem for you.