#!/bin/bash

if test $# = 0; then
    set -- onkey
fi

n1=$(cat /proc/interrupts | grep -e "$1")

for x in $(seq 1 30); do
    n2=$(cat /proc/interrupts | grep -e "$1")
    if test "$n1" = "$n2"; then
	sleep 1
    else
	echo power key interrupt detected:
	echo "before: $n1"
	echo "after:  $n2"
	exit 0
    fi
done

die "Did not get power key interrupt after 30 seconds"
