]> www.wagner.pp.ru Git - sites/home_page.git/blob - software/unix/bringup.sh
Added bringup script to xtitle page, added XVKbd russian layout
[sites/home_page.git] / software / unix / bringup.sh
1 #!/bin/sh
2 TITLE="$1"
3 shift
4 COMMAND=$1
5
6 ttyprefix=/dev/; #for linux systems with /dev/pts
7 cmdcolumn=5 ;# where to find command in ps output
8 ttycolumn=2 ;# where to find tty name in ps output
9 psargs=aww; 
10 get_tty_from_command () {
11   local t
12   t=`ps $psargs|awk "\\$$cmdcolumn~/$1/ {print \"$ttyprefix\" \\$$ttycolumn;exit}"`
13   if [ -z "$t" ]
14      then
15         return 1
16      fi
17   check_tty $t
18 }
19
20 check_tty () {
21   if [ ! -c $1 ] 
22      then
23        echo "$i is not valid tty name" >&2
24        exit 1
25      fi
26   if [ ! -w $1 ]
27      then
28        echo "$i is not writable for you" >&2
29        exit 1
30      fi
31   tty=$1
32 }
33
34 if get_tty_from_command $COMMAND; then
35         echo -n '\e[1t\e[5t' >$tty
36 else
37         xterm -T "$TITLE" -name $COMMAND -e "$@" &
38 fi