/[zanavi_public1]/navit/navit/startonce.sh
ZANavi

Contents of /navit/navit/startonce.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations) (download) (as text)
Fri Oct 28 21:19:04 2011 UTC (12 years, 5 months ago) by zoff99
File MIME type: application/x-sh
File size: 1496 byte(s)
import files
1 #!/bin/sh
2
3 # This script is part of navit, a navigation system.
4 # It can be used to make sure that navit is only started
5 # once. If navit is already running it will be brought to
6 # the front.
7
8 # Set this to a place where a pidfile should be stored.
9 # Make sure you have write access...
10 PIDFILE="/var/run/navit/navit.pid"
11
12 # Set this to navit's executable.
13 NAVIT="./navit"
14
15 # Optional: Set this to an alternative configuration file
16 #CONFIG="./navit.xml"
17
18 ############################################################
19 ### You should not need to edit anything below this line ###
20 ############################################################
21
22 function check_wmctrl()
23 {
24 which wmctrl > /dev/null
25
26 if [ $? -ne 0 ] ; then
27 echo "I need the 'wmctrl' program. Exit."
28 exit 1
29 fi
30 }
31
32 function start_navit()
33 {
34 if [ "x" != "x$CONFIG" ] ; then
35 $NAVIT -c $CONFIG &
36 else
37 $NAVIT &
38 fi
39
40 pid=$!
41
42 echo -n "$pid" > $PIDFILE
43
44 if [ $? -eq 0 ] ; then
45 echo "Started navit with PID $pid."
46 else
47 kill $pid
48 echo "Could not create pidfile!"
49 exit 1
50 fi
51
52 # Waiting for navit to close...
53 wait $pid
54
55 rm $PIDFILE
56 }
57
58 function check_navit()
59 {
60 if [ -f $PIDFILE ] ; then
61 pid=`cat $PIDFILE`
62 kill -0 $pid 2>/dev/null
63 if [ $? -eq 0 ] ; then
64 echo "Bringing Navit to front"
65
66 winid=`wmctrl -l -p | grep -e "^[^:blank:]*[:blank:]*[^:blank:]*[:blank:]*$pid[:blank:]*" | sed 's/ .*//'`
67 wmctrl -i -R $winid
68
69 exit 0
70 fi
71 fi
72 }
73
74
75 ### Start of the main script ###
76
77 check_wmctrl
78
79 check_navit
80
81 start_navit

Properties

Name Value
svn:executable *

   
Visit the ZANavi Wiki