Lines 71-76
Link Here
|
71 |
on run |
71 |
on run |
72 |
if (preRun()) then |
72 |
if (preRun()) then |
73 |
openSoffice("-") |
73 |
openSoffice("-") |
|
|
74 |
if (hasOOoDaemonQuit()) then |
75 |
runOOoDaemon() |
76 |
end if |
74 |
end if |
77 |
end if |
75 |
end run |
78 |
end run |
76 |
|
79 |
|
Lines 82-98
Link Here
|
82 |
|
85 |
|
83 |
on idle |
86 |
on idle |
84 |
-- close icon only if ooo has terminated |
87 |
-- close icon only if ooo has terminated |
85 |
if (hasOOoQuit()) then |
88 |
--if (hasOOoQuit()) then |
86 |
tell me to quit |
89 |
-- tell me to quit |
87 |
end if |
90 |
--end if |
88 |
-- check all x seconds if ok to quit |
91 |
-- check all x seconds if ok to quit |
89 |
return 3 |
92 |
--return 3 |
90 |
end idle |
93 |
end idle |
91 |
|
94 |
|
92 |
on quit |
95 |
on quit |
93 |
if (hasOOoQuit()) then |
96 |
-- kill all OOo instances, all windows and the daemon |
94 |
continue quit |
97 |
set theCmd to "killall soffice.bin" |
95 |
end if |
98 |
do shell script theCmd & " &>/dev/null & echo $!" |
|
|
99 |
logEvent("(scripts/main) OpenOffice.org daemon stopped.") |
100 |
|
101 |
continue quit |
96 |
end quit |
102 |
end quit |
97 |
|
103 |
|
98 |
------------------------------------------------------------- |
104 |
------------------------------------------------------------- |
Lines 133-145
Link Here
|
133 |
return true |
139 |
return true |
134 |
end preRun |
140 |
end preRun |
135 |
|
141 |
|
|
|
142 |
on hasOOoDaemonQuit() |
143 |
if (isRealPath(getOOProgramPath())) then |
144 |
-- set the location of soffice binary |
145 |
set soffice to POSIX path of getOOProgramPath() & "soffice" |
146 |
|
147 |
set isRunning to do shell script "_FOUND_=`ps -wx -o command | grep \"" & soffice & "\" | grep quickstart | grep -v grep `; echo $_FOUND_" |
148 |
if isRunning "" then |
149 |
return false |
150 |
else |
151 |
return true |
152 |
end if |
153 |
else |
154 |
return true |
155 |
end if |
156 |
end hasOOoDaemonQuit |
157 |
|
136 |
|
158 |
|
137 |
on hasOOoQuit() |
159 |
on hasOOoQuit() |
138 |
if (isRealPath(getOOProgramPath())) then |
160 |
if (isRealPath(getOOProgramPath())) then |
139 |
-- set the location of soffice binary |
161 |
-- set the location of soffice binary |
140 |
set soffice to POSIX path of getOOProgramPath() & "soffice" |
162 |
set soffice to POSIX path of getOOProgramPath() & "soffice" |
141 |
|
163 |
|
142 |
set isRunning to do shell script "_FOUND_=`ps -wx -o command | grep \"" & soffice & "\" | grep -v grep`; echo $_FOUND_" |
164 |
set isRunning to do shell script "_FOUND_=`ps -wx -o command | grep \"" & soffice & "\" | grep -v grep | grep -v quickstart`; echo $_FOUND_" |
143 |
if isRunning "" then |
165 |
if isRunning "" then |
144 |
return false |
166 |
return false |
145 |
else |
167 |
else |
Lines 150-155
Link Here
|
150 |
end if |
172 |
end if |
151 |
end hasOOoQuit |
173 |
end hasOOoQuit |
152 |
|
174 |
|
|
|
175 |
-- Run OOo hidden in the background to mimic Mac OS X like behaviour |
176 |
on runOOoDaemon() |
177 |
set theDisplay to startXServer() |
178 |
if (theDisplay is equal to "error") then |
179 |
return |
180 |
end if |
181 |
set theEnv to "DISPLAY=" & theDisplay & " ; export DISPLAY; " |
182 |
set theCmd to "sh \"" & POSIX path of getOOProgramPath() & "soffice" & "\" " |
183 |
do shell script theEnv & theCmd & " -quickstart " & " &>/dev/null & echo $!" |
184 |
logEvent("(scripts/main) OpenOffice.org daemon started.") |
185 |
end runOOoDaemon |
186 |
|
153 |
|
187 |
|
154 |
on openSoffice(aFile) |
188 |
on openSoffice(aFile) |
155 |
set theDisplay to startXServer() |
189 |
set theDisplay to startXServer() |
Lines 271-277
Link Here
|
271 |
-- function for logging script messages |
305 |
-- function for logging script messages |
272 |
on logEvent(themessage) |
306 |
on logEvent(themessage) |
273 |
set theLine to (do shell script  |
307 |
set theLine to (do shell script  |
274 |
"date +'%Y-%m-%d %H:%M:%S'" as string) Â |
308 |
"date +\"%Y-%m-%d %H:%M:%S\"" as string) Â |
275 |
& " " & themessage |
309 |
& " " & themessage |
276 |
do shell script "echo '" & theLine & "'" & Â |
310 |
do shell script "echo '" & theLine & "'" & Â |
277 |
" >> ~/Library/Logs/OpenOffice2.log" |
311 |
" >> ~/Library/Logs/OpenOffice2.log" |