]> wagner.pp.ru Git - sites/home_page.git/blobdiff - software/unix/bringup.sh
Added bringup script to xtitle page, added XVKbd russian layout
[sites/home_page.git] / software / unix / bringup.sh
diff --git a/software/unix/bringup.sh b/software/unix/bringup.sh
new file mode 100644 (file)
index 0000000..efc8739
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+TITLE="$1"
+shift
+COMMAND=$1
+
+ttyprefix=/dev/; #for linux systems with /dev/pts
+cmdcolumn=5 ;# where to find command in ps output
+ttycolumn=2 ;# where to find tty name in ps output
+psargs=aww; 
+get_tty_from_command () {
+  local t
+  t=`ps $psargs|awk "\\$$cmdcolumn~/$1/ {print \"$ttyprefix\" \\$$ttycolumn;exit}"`
+  if [ -z "$t" ]
+     then
+        return 1
+     fi
+  check_tty $t
+}
+
+check_tty () {
+  if [ ! -c $1 ] 
+     then
+       echo "$i is not valid tty name" >&2
+       exit 1
+     fi
+  if [ ! -w $1 ]
+     then
+       echo "$i is not writable for you" >&2
+       exit 1
+     fi
+  tty=$1
+}
+
+if get_tty_from_command $COMMAND; then
+       echo -n '\e[1t\e[5t' >$tty
+else
+       xterm -T "$TITLE" -name $COMMAND -e "$@" &
+fi