I made this (on a piece of leftover junk PCB) to remotely switch an external HDD connected to my home server on/off.
I went with the "Safer New Design" from here, but then decided to opto-isolate it anyway. An LPT port data pin switches the led in a 4N25 opto-coupler, which then switches an external power brick's connection to the board. The relay then switches the mains on an extension cord. I pulled the NAIS 5v/220V relay from a broken monitor. Although with this design the switching voltage isn't really that important. As long as it's within the accepted ranges of the opto-coupler and transistor.
Coded up this simple command-line tool in FreeBasic to use it with:
dim as string myCmd
dim as ubyte myState
myCmd = ucase(command$(1))
if myCmd <> "ON" and myCmd <> "OFF" then goto state
if myCmd = "ON" then out &h378,1
if myCmd = "OFF" then out &h378,0
myState = inp(&h378)
if myState = 0 then print "Relay is OFF" else print "Relay is ON"
I decided to release my board layout along with some notes on this project, in case anyone wants to build this. The notes say it all.
In case you build it, leave a comment :)