Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Droplet to open files with X11 app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Droplet to open files with X11 app
Authored by: mbclark on Jan 26, '03 03:52:00PM
I was just working on a droplet open one or more text files with Nedit when I ran across this tip. I just keep the droplet on my desktop for easy access. Here's the code for the droplet if anyone's interested. It could easily be modified to work with just about any X app.
on open these_items	
	tell application "Finder"		
		--Launch X11 and bring to front
		launch application "X11"
		--String that will be executed by the do shell script command
		--First set the display
		set theCommand to "export DISPLAY=':0.0'; /sw/bin/nedit "
		
		--Process each file dropped on the droplet, appending the 
		--POSIX path of the file to the end of "theCommand"
		set theFiles to these_items as string
		repeat with i from 1 to the count of these_items
			set theFile to POSIX path of (item i of these_items as string)
			set theFiles to these_items as string
			set theCommand to theCommand & " " & theFile
		end repeat
		
		-- Finish theCommand string
		-- Pipe output to stdout and stderr so the command 
		-- returns and AppleScript won't wait around for 
		-- stdout and stderr to close
		set theCommand to theCommand & "> /dev/null 2>&1 &"
		do shell script theCommand
	end tell
end open


[ Reply to This | # ]