Latching relay circuit with timed override



I can't quite figure out how to do this, and I'm hoping someone might
have a suggestion.

I'm trying to achieve the following behavior in a system:

- When a momentary pushbutton is pressed the system powers on.
- When the pushbutton is pressed again, nothing happens (i.e. the power
stays on).
- When the pushbutton is held down for x seconds, the system powers
off.

In other words, I'm trying to replicate the behavior of computer ATX
power switches (in fact the system contains an ATX supply). The design
I have right now has a couple of diodes and a SPDT relay. What I have
right now is the following: Vbattery feeds into the pushbutton, then to
a diode, and then into the relay coil which connects to ground. I also
connect Vatx through a diode to the coil input (so the coil input
floats at the higher diode output). The load loop (simplified) goes
from Vbattery through the normally open relay contact, then to the atx
supply, and then to ground. When the pushbutton is pressed from an
"off" state, the coil will energize, close the relay, and power will go
to the atx supply. When the atx turns on, it feeds Vatx to the relay
coil via the diode, thus keeping the relay closed when the pushbutton
is released. (There might be a cap at the coil input to give it an
extra push in case the pushbutton is released too quickly?). That, I
think, takes care of the latching, but now I'm not sure how to turn it
off. I'm pretty sure I can use some long time constant RC circuit to
reduce the voltage across the coil and open the relay, but I'm not sure
how to do it. I need to use the same pushbutton. Right now, once the
relay is latched, pressing the button won't do anything (actually it
will probably cause the battery to drive the coil instead of the atx
while it is depressed since Vbattery is 12+V and Vatx is 12, but the
*effect* will be nothing). Seems to me I could connect an RC
arrangement between the pushbutton and the diode on the battery line,
and charge it by holding the button down. But I don't know how to
interface it to the rest of the circuit. I thought about feeding the
charging cap to a FET or something to break the coil circuit, but that
would probably require a comparator etc and seems unnecessary. I'd
greatly appreciate any advice anybody could offer.

Some things to note:
1. I'm not totally (stress *totally*) insane - there are reasons why
I'm trying to control the atx like this, the main one being that when
the atx is turned off, it's not totally off (the mainboard still draws
power for wake-up junk) and I need absolutely zero current draw when in
the off state.
2. Actually turning the atx on requires some additional stuff, like a
timed pulse to shunt the power-on pins to actually get things going.
The button will have to remain depressed througout this period (unless
there's a better way). Right now I'm going to use a little micro and
fet to do this.
3. The power-off override needs to be fairly no-nonsense, which is why
I don't want to rely on the micro to handle it. I'd really like it if I
could keep this part of the circuit analog, as I think it's the next
best thing to a mechanical switch.
4. If you've gotten this far, I really appreciate it. Thanks.

.