-- white_dune-Launcher for new Apple X11
-- this file can be used to start white_dune with commandline parameters

on open droppedFiles
	my ProcessFiles(droppedFiles)
end open

on ProcessFiles(rawFiles)
	set theFiles to {}
	set xdisplay to "localhost:0.0" as string
	set dunepath to "/usr/local/bin/dune" as string
	set addparms to "-nostereo -spaceball /dev/tty.pico -all=2,5,,0.0000002" as string
	set debugopts to "2>&1 >>~/dune.log" as string
	
	repeat with i from 1 to the count of rawFiles
		set theFiles to theFiles & POSIX path of (item i of rawFiles as alias) & " "
	end repeat
	
	set shellcall to dunepath & " -display " & xdisplay & " " & addparms & " " & theFiles & " " & debugopts & " & " as string
	
	do shell script "echo " & shellcall
	
	try
		tell application "X11"
			run
			activate
			try
				do shell script shellcall
			on error errmsg
				display dialog "dune failed (" & errmsg & "), please log out and log in !"
			end try
		end tell
	on error errmsg
		display dialog "X11 failed (" & errmsg & "), please log out and log in !"
	end try
	
end ProcessFiles


