slackfr
Aktives Mitglied
Thread Starter
- Dabei seit
- 20.02.2006
- Beiträge
- 425
- Reaktionspunkte
- 1
suche nach einer möglichkeit X11-Programme mit bestimmer Datei-Typen über skript zu Verbinden,
habe dazu dies hier gefunden, jedoch auch nach der umänderung auf mein Programm (GNUmeric) und den nötogen Datei-Typen wird das Programm nicht ausgeführt.
so sieht das skript bei mir aus, jedoch wird bei starten einer datei über das skript der Fehler angezeigt: "The variable currentProgram is not defined"
habe dazu dies hier gefunden, jedoch auch nach der umänderung auf mein Programm (GNUmeric) und den nötogen Datei-Typen wird das Programm nicht ausgeführt.
so sieht das skript bei mir aus, jedoch wird bei starten einer datei über das skript der Fehler angezeigt: "The variable currentProgram is not defined"
Code:
-- ProgramLauncher.applescript
-- ProgramLauncher
tell application "Finder"
launch application "X11"
activate
end tell
global currentProgram
global currentProgramFancy
set currentProgram to "gnumeric-1.6.3"
set currentProgramFancy to "gnumeric-1.6.3"
-- the list of file types which will be processed, then list of extensions if there is no type
property type_list : {"XLS", "DOC"}
property extension_list : {"xls", "doc"}
-- Variable used to see if we should just run the program (if no files are passed in.)
global prog_launched
set prog_launched to false
on open these_items
set prog_launched to true
if ((count of these_items) > 0) then
repeat with i from 1 to the count of these_items
set this_item to (item i of these_items)
set the item_info to info for this_item
if (folder of the item_info is false) and ¬
(alias of the item_info is false) and ¬
((the file type of the item_info is in the type_list) or ¬
the name extension of the item_info is in the extension_list) then
set results to do shell script "cd ~; DISPLAY=:0.0;
export DISPLAY; PATH=$PATH:/sw/bin; export PATH ;
/sw/bin/" & currentProgram & " " & quoted form of POSIX path of this_item & " > /dev/null 2>&1 &"
delay 2
else
display dialog "Sorry " & currentProgramFancy & ", can't open this file type."
end if
end repeat
end if
end open
-- So the user double-clicked on the icon. Better just launch!
-- Now, if this was really smart, it'd check the process list to
-- see if the program was already running and bring it to the front
-- instead. Me, I still find AppleScript annoying, so I'll do
-- without that for now. ;-)
if not (prog_launched) then
set results to do shell script "cd ~; DISPLAY=:0.0;
export DISPLAY; PATH=$PATH:/sw/bin; export PATH ;
/sw/bin/" & currentProgram & " > /dev/null 2>&1 &"
end if