#!/bin/sh
# (c) Robert Shingledecker 2010
# Called from startx to setup initial openbox system, tce, & ondemand menus.

writeMenuItem() {
/bin/busybox awk '
BEGIN {
  FS = "="
}
{
  if ( $1 == "Name") {
    name = $2 $3 $4 $5
    gsub(/ /, "_", name)
  } else if ( $1 == "Exec" ) {
    exec = $2 $3 $4 $5
    test = match(exec,"%")
    if ( test ) exec = substr(exec,0,test-1)
  } else if ( $1 == "Terminal" ) {
    terminal = $2
  }
}
END {
  if ( terminal == "true" ) {
    print "<item label=\""name"\"> <action name=\"Execute\"> <command> xterm +sb -T \""name"\" -e " exec "</command> </action> </item>"
  } else {
    print "<item label=\""name"\"> <action name=\"Execute\"> <command>"exec"</command> </action> </item>"
  }
} ' "$1"
}
