File: GRASS.applescript

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (69 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--  Created by William Kyngesburye on 2006-12-12.
--  GRASS Applescript startup
--  COPYRIGHT: (C) 2006-2008 by the GRASS Development Team
-- 	This program is free software under the GPL (>=v2)
--	Read the file COPYING that comes with GRASS for details.

-- note: handler order on launch:
--   1-will finish launching (good place to check prefs; no nibs loaded yet)
--   2-launched (good place to show initial windows or dialogs)
--   2.5-open?
--   3-idle (waits for user action)
--
-- idle is supposed to be last, but open seems to cause it to think
-- it's not idle, so we can process drag-n-drop before idling.  No docs
-- say explicitly that this is the case, so speed of Mac and process load
-- could affect this.

property grassMap : ""
property grassGui : ""
property grassLaunched : false

on will finish launching theObject
	set grassLaunched to false
	-- eventually, catch modifier key here? to show gui choice
end will finish launching

--on launch theObject
--end launch

on open maps
	--display dialog (count of maps)
	if count of maps is 1 then
		if (folder of (info for (item 1 of maps))) then
			set grassMap to " " & (quoted form of (POSIX path of (item 1 of maps)))
		end if
	end if
	launchgrass()
end open

on idle theObject
	if not grassLaunched then
		launchgrass()
	end if
end launched

on launchgrass()
	set grassLaunched to true
	set grass_path to (posix path of (path to me as string)) & "Contents/MacOS/"
	set grass_startup to (quoted form of (grass_path & "grass.sh"))
	set grassRun to grass_startup & grassGui & grassMap & "; exit"

	set TerminalRunning to false
	try
		if ((do shell script "ps -axc | grep '\\bTerminal\\b'") is not null) then
			set TerminalRunning to true
		end if
	end try

	tell application "Terminal"
		activate
		if TerminalRunning then
			do script (grassRun)
		else
			do script (grassRun) in window 1
		end if
	end tell

	tell me to quit
end launchgrass