forked from ghaerr/microwindows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunapp
More file actions
executable file
·149 lines (136 loc) · 2.96 KB
/
Copy pathrunapp
File metadata and controls
executable file
·149 lines (136 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
#
# Wrapper script to run Microwindows applications from inside the source tree
# The Nano-X server will be started if necessary
#
# Usage: ./runapp [-p|-L|-R|-D|-A] [bin/]application [arguments]
# -p no server quit on application exit
# -L left portrait mode
# -R right portrait mode
# -D upside down portrait mode
# -A auto switch portrait mode with mouse at screen edge
#
appdir=bin
# first determine the directory that contains this script itself
scriptdir=""
scriptname=$0
case "$0" in
*/*)
# $0 contains a path, use it
scriptdir=`dirname "$0"`
scriptname=`basename "$0"`
;;
*)
# no directory in $0, search in PATH
saved_ifs=$IFS
IFS=:
for d in $PATH
do
IFS=$saved_ifs
if [ -x "$d/$scriptname" ]
then
scriptdir="$d"
break
fi
done
;;
esac
# now find the top-level directory of the build tree
if [ -x "$scriptdir/bin/nano-X" ]
then topdir="$scriptdir"
elif [ -x "$scriptdir/../bin/nano-X" ]
then topdir="$scriptdir/.."
elif [ -x "$scriptdir/../../bin/nano-X" ]
then topdir="$scriptdir/../.."
elif [ -x "$scriptdir/../../../bin/nano-X" ]
then topdir="$scriptdir/../../.."
else
topdir="."
fi
topdir=`cd "$topdir" && pwd`
bindir=$topdir/bin
serverargs=
# Check for Nano-X server argument
case "$1" in
-*)
serverargs=$1
shift
;;
esac
progname=$1
# now find application specified
if [ "$progname" = "" ]
then
# no app specified, give usage
ls -C $appdir
echo -n "Please enter demo program name: "
read progname
fi
if [ "$progname" = "" ]
then
# no app specified, exit
exit 1
fi
case "$progname" in
*/*)
# progname contains a path, use it
application=$progname
;;
*)
# no directory in progname
application=$appdir/$progname
;;
esac
# check if application present
if [ ! -x $application ]
then
echo "$scriptname: can't find $application"
exit 1
fi
# determine if nano-X server required
appname=`basename "$application"`
case "$appname" in
mw*)
need_server=NO
;;
*)
need_server=YES
;;
esac
# setup the environment
if [ "`uname -s`" = "Darwin" ]
then
if [ -n "$DYLD_LIBRARY_PATH" ]
then
DYLD_LIBRARY_PATH="$topdir/lib:$DYLD_LIBRARY_PATH"
else
DYLD_LIBRARY_PATH="$topdir/lib"
fi
export DYLD_LIBRARY_PATH
else
if [ -n "$LD_LIBRARY_PATH" ]
then
LD_LIBRARY_PATH="$topdir/lib:$LD_LIBRARY_PATH"
else
LD_LIBRARY_PATH="$topdir/lib"
fi
export LD_LIBRARY_PATH
fi
NANOXSERVER="$bindir/nano-X"
#echo $need_server $NANOXSERVER $application libs=$DYLD_LIBRARY_PATH libs=$LD_LIBRARY_PATH
# now check if nano-X server needs to be run, and exec application
shift
server_running=`ps | grep nano-X | sed '/grep/d'`
if [ "$need_server" = "YES" ] && [ "$server_running" = "" ]
then
# find nano-X server
if [ -x "$bindir/nano-X" ]
then NANOXSERVER="$bindir/nano-X"
else
echo "$scriptname: could not find nano-X server in $bindir"
exit 1
fi
$NANOXSERVER $serverargs & exec $application $@
else
exec $application $@
fi