#!/bin/bash

PATH=/sbin:/bin/:/usr/sbin:/usr/bin:/live/bin

my_dir=${0%/*}
log_file=/live/config/tsplash/tsplash.log
tty=10

get_seconds() {
    local msecs=${1:-$(cut -d" " -f22 /proc/self/stat)}
    printf "%06d" $msecs | sed  -r 's/(..)$/.\1/'
}

header="\n---------------------------"
printf "$header\n[%8s] CMD: %s\n" "$(get_seconds)" "$*" >> $log_file

pgrep -x tsplash >/dev/null && return

openvt -c $tty $my_dir/tsplash "$@" 2>>$log_file
