2 #------------------------------------------------------------------------------
4 # This shell script attempts to intelligently manage the process
5 # of launching a program with Wine. It adds some level of
6 # visual feedback to an end user.
9 # winelauncher [options] "<windows program> [program arguments]"
11 # This script is meant to be installed to /usr/bin/wine, and
12 # to be used to invoke a Windows executable.
13 # The options are passed through directly to Wine, and are
14 # documented in the Wine man page.
16 # Copyright (c) 2000 by Jeremy White for CodeWeavers
18 #------------------------------------------------------------------------------
20 #------------------------------------------------------------------------------
21 # Primary configuration area - change this if you installed Wine to
22 # a location other than @prefix@
23 #------------------------------------------------------------------------------
26 #------------------------------------------------------------------------------
27 # Secondary configuration area; change these at your own risk.
28 #------------------------------------------------------------------------------
29 exec_prefix
=@exec_prefix@
35 #------------------------------------------------------------------------------
36 # Establish Color Scheme
37 #------------------------------------------------------------------------------
38 COLOR
=' -xrm *.Command.background:darkgrey
39 -xrm *.Command.foreground:black
40 -xrm *.Text.background:black
41 -xrm *.Text.foreground:green
42 -xrm *.Form.background:grey
43 -xrm *.Form.foreground:green
44 -xrm *.foreground:green
45 -xrm *.background:black'
48 XMESSAGE
="xmessage $COLOR"
51 #------------------------------------------------------------------------------
52 # We're going to do a lot of fancy footwork below.
53 # Before we get started, it would be nice to know the argv0,
54 # of the actual script we're running (and lets remove at least
55 # one level of symlinking).
56 #------------------------------------------------------------------------------
57 real_name
=`find $0 -type l -printf "%l\n"`
58 if [ ! $real_name ]; then
61 argv0_dir
=`find $real_name -printf "%h\n"`
63 if [ -z $argv0_dir ] ; then
67 #------------------------------------------------------------------------------
68 # Okay, now all that junk above was established at configure time.
69 # However, if this is an RPM install, they may have chosen
70 # to relocate this installation. If so, that stuff above
71 # is all broken and we should rejigger it.
72 #------------------------------------------------------------------------------
73 WINE_BIN_NAME
=wine.bin
74 if [ ! -x $WINEBIN/$WINE_BIN_NAME ] ; then
75 WINEBIN
=`find $argv0_dir -maxdepth 1 -perm +0111 -type f -name "$WINE_BIN_NAME" -printf "%h\n" | head -1`
78 if [ ! -x $WINEBIN/$WINE_BIN_NAME ] ; then
79 WINEBIN
=`find $argv0_dir/../ -maxdepth 1 -perm +0111 -type f -name "$WINE_BIN_NAME" -printf "%h\n" | head -1`
82 if [ ! -x $WINEBIN/$WINE_BIN_NAME ] ; then
84 if [ ! -x $WINEBIN/$WINE_BIN_NAME ] ; then
85 WINEBIN
=`find $argv0_dir -maxdepth 1 -perm +0111 -type f -name "$WINE_BIN_NAME" -printf "%h\n" | head -1`
88 if [ ! -x $WINEBIN/$WINE_BIN_NAME ] ; then
89 WINEBIN
=`find $argv0_dir/../ -maxdepth 1 -perm +0111 -type f -name "$WINE_BIN_NAME" -printf "%h\n" | head -1`
93 if [ ! -r $WINELIB/libwine.so
] ; then
94 WINELIB
=`find $argv0_dir -maxdepth 2 -name 'libwine.so' -printf "%h\n" | head -1`
97 if [ ! -r $WINELIB/libwine.so
] ; then
98 WINELIB
=`find $argv0_dir/../ -maxdepth 2 -name 'libwine.so' -printf "%h\n" | head -1`
101 if [ -x $WINEBIN/wineserver
] ; then
102 WINESERVER
=$WINEBIN/wineserver
105 #------------------------------------------------------------------------------
106 # Hey, if we built Wine from source, let's add a little extra fun to
108 #------------------------------------------------------------------------------
109 if [ -x $WINEBIN/server
/wineserver
] ; then
110 WINESERVER
=$WINEBIN/server
/wineserver
113 if [ -r $WINELIB/dlls
/libuser.so
] ; then
114 WINELIBDLLS
=$WINELIB/dlls
118 #------------------------------------------------------------------------------
119 # Okay, set the paths and move on.
120 #------------------------------------------------------------------------------
121 export LD_LIBRARY_PATH
=$WINELIB:$WINELIBDLLS:$LD_LIBRARY_PATH
122 export PATH
=$WINEBIN:$PATH
123 export WINEDLLPATH
=$WINELIBDLLS
124 export WINELOADER
=$WINEBIN/$WINE_BIN_NAME
126 info_flag
=~
/.wine
/.no_prelaunch_window_flag
127 debug_flag
=~
/.wine
/.no_debug_window_flag
128 debug_options
="-debugmsg warn+all"
130 if [ -f $info_flag ] ; then
136 if [ -f $debug_flag ] ; then
143 #------------------------------------------------------------------------------
144 # No arguments? Help 'em out
145 #------------------------------------------------------------------------------
148 if [ $# -eq 0 ] ; then
152 if [ $# -eq 1 -a foo
$1 = foo
] ; then
156 if [ $no_args -eq 1 ] ; then
157 echo "Wine called with no arguments."
158 echo "Invoking $WINEBIN/$WINE_BIN_NAME $@ ..."
159 $XMESSAGE -buttons " Okay ":0," See the Wine Usage Statement ":1," Configure Wine ":2 \
160 -title "Welcome to Wine" \
163 You have started Wine without specifying any arguments.
165 Wine requires a least one argument - the name of the Windows
166 application you would like to run.
168 If you have launched this through the KDE menu system,
169 you can use the KDE file browser to select a Windows
170 exectuable and then click on it to launch Wine with
173 You can similarly use the GNOME file manager to
174 select a Windows executable and double click on it.
176 If you would like to see the command line arguments
177 for Wine, select the second option, below.
181 if [ $welcome_rc -eq 0 ] ; then
185 if [ $welcome_rc -eq 2 ] ; then
187 if [ $?
-eq 0 ] ; then
190 if [ -x /opt
/wine
/bin
/winesetup
] ; then
191 /opt
/wine
/bin
/winesetup
193 $XMESSAGE -title "Error" "Error: Unable to find winesetup in your PATH or in /opt/wine/bin"
203 #------------------------------------------------------------------------------
204 # No config file? Offer to help 'em out...
205 #------------------------------------------------------------------------------
208 while [ $conf -eq 0 ] ; do
210 if [ -f ~
/.winerc
] ; then
213 if [ -f ~
/.wine
/config
] ; then
216 if [ -f /etc
/wine.conf
] ; then
220 if [ $conf -ne 0 ] ; then
224 echo "No configuration file detected."
225 $XMESSAGE -buttons " Cancel ":0," Proceed ":1," Configure Wine ":2 \
226 -title "Welcome to Wine" \
229 You have started Wine but we cannot find a Wine
232 This is normal if you have never run Wine before.
233 If this is the case, select the 'Configure Wine'
234 option, below, to create a configuration file.
238 if [ $init_rc -eq 0 ] ; then
242 if [ $init_rc -eq 1 ] ; then
246 if [ $init_rc -eq 2 ] ; then
248 if [ $?
-eq 0 ] ; then
251 if [ -x /opt
/wine
/bin
/winesetup
] ; then
252 /opt
/wine
/bin
/winesetup
254 $XMESSAGE -title "Error" "Error: Unable to find winesetup in your PATH or in /opt/wine/bin"
261 #------------------------------------------------------------------------------
262 # Optionally Warn the user we're going to be launching Wine...
263 #------------------------------------------------------------------------------
264 if [ $use_info_message -ne 0 ] ; then
265 echo "Invoking $WINEBIN/$WINE_BIN_NAME $@ ..."
266 $XMESSAGE -timeout 30 -buttons " Dismiss ":0," Never display this message again ":3 \
267 -title "Wine Launch Window" \
268 "Invoking $WINEBIN/$WINE_BIN_NAME $@ ...
270 This dialog box is a temporary status dialog to let you know
271 that Wine is attempting to launch your application.
273 Since Wine is still very much in a development stage, many
274 applications will fail silently. This dialog box is your indication
275 that we're *trying* to run your application.
277 This dialog box will automatically disappear after 30 seconds,
278 or after your application finishes.
280 You can permanently disable this dialog by selecting the option below.
285 #------------------------------------------------------------------------------
286 # Here's a little function to clean up after that dialog...
287 #------------------------------------------------------------------------------
288 function clean_up_info_message
()
290 if [ $use_info_message -ne 0 ] ; then
292 #------------------------------------------------------------------------------
293 # Okay, make sure that the notice window is dead (and kill it if it ain't)
294 #------------------------------------------------------------------------------
295 ps
$info_message_pid >/dev
/null
2>&1
296 if [ $?
-ne 0 ] ; then
297 wait $info_message_pid
301 kill $info_message_pid
304 #------------------------------------------------------------------------------
305 # If they didn't like the warning window, turn it off
306 #------------------------------------------------------------------------------
307 if [ $info_return -eq 3 ] ; then
308 $XMESSAGE -title "Wine Prelaunch Control" \
309 "Wine will now disable the prelaunch Window you just saw.
310 You will no longer be notified when Wine is attempting
311 to start a Windows application.
313 You can reenable this Window by removing the $info_flag file." -buttons " Okay ":0," Cancel ":1
314 if [ $?
-eq 0 ] ; then
322 #------------------------------------------------------------------------------
323 # Generate a temporary log file name
324 #------------------------------------------------------------------------------
326 log_name
=`mktemp /tmp/wine.log.XXXXXX`
327 if [ $?
-eq 0 ] ; then
328 which tail >/dev
/null
2>&1
329 if [ $?
-eq 0 ]; then
334 #------------------------------------------------------------------------------
335 # Okay, really launch Wine...
336 #------------------------------------------------------------------------------
337 if [ $use_log_name -ne 0 ] ; then
338 #------------------------------------------------------------------------------
339 # Okay, we bend over backwards to run Wine, get that status,
340 # but still display its output to the screen.
341 # The obvious thing to do is to run wine and pipe output to tee,
342 # but then I can't find a way to get the return code of wine;
343 # I only get the return code of tee.
344 #------------------------------------------------------------------------------
345 $WINEBIN/$WINE_BIN_NAME "$@" >$log_name 2>&1 &
356 $WINEBIN/$WINE_BIN_NAME "$@"
360 #------------------------------------------------------------------------------
361 # Test the return code, and see if it fails
362 #------------------------------------------------------------------------------
363 if [ $always_see_output -eq 0 -a $wine_return -eq 0 ] ; then
364 echo "Wine exited with a successful status"
365 if [ $use_log_name -ne 0 ] ; then
369 if [ $always_see_output -eq 0 ] ; then
370 echo "Wine failed with return code $wine_return"
373 #------------------------------------------------------------------------------
374 # Gracefully display a debug message if they like...
375 #------------------------------------------------------------------------------
376 while [ $use_debug_message -gt 0 ] ; do
378 #------------------------------------------------------------------------------
379 # Build up the menu of choices they can make...
380 #------------------------------------------------------------------------------
382 if [ $use_log_name -ne 0 ] ; then
383 BUTTONS
="$BUTTONS"', View Log :1'
386 BUTTONS
="$BUTTONS"', Debug :2'
387 BUTTONS
="$BUTTONS"', Configure :4'
388 BUTTONS
="$BUTTONS"', Disable :3'
390 #------------------------------------------------------------------------------
391 # Build an error message
392 #------------------------------------------------------------------------------
394 Wine has exited with a failure status of $wine_return.
396 Wine is still development software, so there can be many
397 explanations for this problem.
399 You can choose to run Wine again with a higher level
400 of debug messages (the debug option, below).
402 You can attempt to reconfigure Wine to make it work better.
403 Note that one change you can make that will dramatically
404 effect Wine's behaviour is to change whether or not
405 Wine uses a true Windows partition, mounted under Linux,
406 or whether it uses an empty Windows directory.
407 The Wine Configuration program can assist you in making
408 those changes (select Configure, below, for more).
410 You can disable this message entirely by selecting the
411 Disable option below."
413 if [ $always_see_output -ne 0 -a $wine_return -eq 0 ] ; then
415 Wine has exited with a failure status of $wine_return.
417 You can disable this message entirely by selecting the
418 Disable option below."
422 if [ $use_log_name -ne 0 ] ; then
425 Wine has captured a log of the Wine output in the file $log_name.
426 You may view this file by selecting View Log, below."
429 #------------------------------------------------------------------------------
430 # Display the message
431 #------------------------------------------------------------------------------
432 $XMESSAGE -title "Wine Finished With Error" -buttons "$BUTTONS" "$MESSAGE"
435 #------------------------------------------------------------------------------
436 # Dismiss the other window...
437 #------------------------------------------------------------------------------
438 clean_up_info_message
440 #------------------------------------------------------------------------------
441 # Process a configure instruction
442 #------------------------------------------------------------------------------
443 if [ $debug_return -eq 4 ] ; then
445 if [ $?
-eq 0 ] ; then
448 if [ -x /opt
/wine
/bin
/winesetup
] ; then
449 /opt
/wine
/bin
/winesetup
451 $XMESSAGE -title "Error" "Error: Unable to find winesetup in your PATH or in /opt/wine/bin"
457 #------------------------------------------------------------------------------
458 # Process a view instruction
459 #------------------------------------------------------------------------------
460 if [ $debug_return -eq 1 ] ; then
461 $XMESSAGE -title "View Wine Log" -file $log_name -buttons " Okay ":0,"Delete $log_name":1
462 if [ $?
-eq 1 ] ; then
463 echo "Deleting $log_name"
471 #------------------------------------------------------------------------------
472 # If they didn't like the warning window, turn it off
473 #------------------------------------------------------------------------------
474 if [ $debug_return -eq 3 ] ; then
475 $XMESSAGE -title "Wine Debug Log Control" \
476 "Wine will now disable the Wine debug output control window you just saw.
477 You will no longer be notified when Wine fails to start a
480 You can reenable this Window by removing the $debug_flag file." -buttons " Okay ":0," Cancel ":1
482 if [ $?
-eq 0 ] ; then
488 #------------------------------------------------------------------------------
489 # If they want to retry with debug, let 'em.
490 #------------------------------------------------------------------------------
491 if [ $debug_return -eq 2 ] ; then
492 echo "Rerunning $0 $debug_options $@"
493 exec $0 $debug_options $@
499 clean_up_info_message