Coded app built with osacompile
Programmatically I am trying to achieve this on Mac OS X: a file on the desktop that, when clicked, launches firefox with a specific profile.
I am doing this with AppleScript and bash.
Manual steps
- Open the Script editor
- Write AppleScript (
do shell script "/Applications/Firefox.app/Contents/MacOS/firefox -ProfileManager &> /dev/null &"
) - Save New AppleScript> Save As> App Package
- Setting icon
It works fine by hand, it follows from this tutorial: Asa Dotzler Blog Firefox Shortcut
However, programmatically I am having some problems.
I successfully make a file and put it on my desktop with /bin/bash/osacompile -
.
Progmatic steps
-
Progrmatcic Step 1 - Create a script.txt file with the code on your desktop
var path_src = OS.Path.join( OS.Constants.Path.desktopDir, 'script.txt' ); var path_exe = FileUtils.getFile('XREExeF', []).path; var write_file = OS.File.writeAtomic( path_src, 'do shell script "' + path_exe + ' -P -no-remote &> /dev/null &"' );
-
Compile the .txt to .app and put it in your working code:
var path_compile = OS.Path.join(OS.Constants.Path.desktopDir,'script.app'); var osacompile = File.initWithPath("/usr/bin/osacompile"); if (MacVersion <= 10.6) { osacompile.arguments = ["-o", path_compile, path_src] } else { //for >= 10.7 osacompile.arguments = [ "-t", "osas", "-c", "ToyS", "-o", path_compile, path_src ] } osacompile.run();
But when the user clicks on them, they get this error: "script" cannot be opened because it is from an unidentified developer. "IMG:
I heard maybe it could be code signed? Could you please help me sign the code so I can work around this error and start working on customizing the icon.
source to share
A simple Google search for "applescript code mark" reveals a lot of information.
Another option, if the code runs on your computer, you can simply disable the system preference that is causing this. Go to Security & Privacy → General and check the box next to Allow downloading apps from anywhere. Of course, understand that this will do exactly what it says, so this is a possible security issue. I start my computer this way, but you may feel differently.
Thus, any of these methods will help solve your problem. Good luck.
source to share