there’s no place like code

delay.sh

Originally posted at saji-codes tumblr.

#!/bin/sh

if ! (( "$#" )) ; then
  printf "USAGE: %s \n" "`basename "$0"`"
  exit
fi

tmp="`mktemp`"
printf 1 > "$tmp"

notify-more \
        "will launch $*" \
        --action-text="don't!" \
        --action-cmd="printf 0 > \"$tmp\""

exec=`cat "$tmp"`
rm "$tmp"

if (( $exec )); then
  exec "$@"
fi

Delayed execution of a command. I use it, so after I log-in and openbox is run, it also runs gnome-session(1) after a while. But I have few seconds to cancel.

notify-more is a more advanced replacement for notify-send(1) from libnotify.