Skip to content

Commit 7246cbf

Browse files
committed
Updated documentation
1 parent be0ae84 commit 7246cbf

File tree

4 files changed

+104
-95
lines changed

4 files changed

+104
-95
lines changed

Documentation/Documentation.html

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ <h3 id="how-does-platypus-work-">How does Platypus work?</h3>
342342
<p>Platypus creates application bundles with a special executable binary that runs a script and captures its output. The binary can be configured to present the script&#39;s text output in various ways, for example by showing a progress bar, a text view, a Status Item menu or a WebKit-based web view.</p>
343343
<h3 id="what-platypus-is-not">What Platypus is NOT</h3>
344344
<p>Platypus is <strong>not</strong> a set of bindings between the native macOS APIs and scripting languages. It is not a full GUI development environment and is not intended for creating substantial applications with complex and dynamic user interaction. If you want to create advanced macOS applications, you should learn to program using the Cocoa APIs. Platypus is not and never will be a substitute for learning to use the native application programming interfaces.</p>
345-
<p>That being said, you may be able to add some interactive GUI elements using something like <a href="https://www.bluem.net/en/projects/pashua/">Pashua</a> or <a href="#prompting-for-input-via-osascript-applescript">AppleScript</a>.</p>
345+
<p>That being said, you may be able to add some interactive GUI elements using something like <a href="https://github.com/BlueM/Pashua">Pashua</a> or <a href="#prompting-for-input-via-osascript-applescript">AppleScript</a>.</p>
346346
<h3 id="system-requirements">System Requirements</h3>
347347
<p>Both Platypus and the applications it generates require <strong>macOS 11</strong> or later and are provided as <strong>64-bit ARM/Intel</strong> binaries. If you want to target macOS 10.8-10.15, use <a href="https://sveinbjorn.org/files/software/platypus/platypus5.3.zip">version 5.4.1</a>.
348348
If you want to target 10.6 and/or 32-bit Intel systems,
@@ -450,8 +450,10 @@ <h3 id="saving-and-loading">Saving and Loading</h3>
450450
<p><img src="images/profiles.png" width="212"></p>
451451
<h3 id="using-profiles-with-the-command-line-tool">Using Profiles with the Command Line Tool</h3>
452452
<p>Profiles can be used with the <code>platypus</code> command line tool. This allows you to set all the settings for your application within the graphical user interface, save them as a profile and then load the settings with the command line app. This makes automation more convenient. The following command would load a profile with the command line tool and create an app from it named MyApp.app:</p>
453-
<pre><code>/usr/local/bin/platypus -P myProfile.platypus MyApp.app
454-
</code></pre><p>See the command line tool man page for further details. An HTML version of the man page is <a href="https://sveinbjorn.org/files/manpages/platypus.man.html">available here</a>.</p>
453+
<div class="highlight"><pre>/usr/local/bin/platypus -P myProfile.platypus MyApp.app
454+
</pre></div>
455+
456+
<p>See the command line tool man page for further details. An HTML version of the man page is <a href="https://sveinbjorn.org/files/manpages/platypus.man.html">available here</a>.</p>
455457
<h3 id="platypus-profile-format">Platypus Profile Format</h3>
456458
<p>Platypus Profiles are standard macOS <a href="https://en.wikipedia.org/wiki/Property_list">property lists</a> in XML format. They can be edited using either a plain text editor or Xcode.</p>
457459
<p>As of version 5.2, Platypus understands and resolves relative paths in Profiles. However, neither the Platypus app nor the command line tool <em>generate</em> relative paths, so if you want to use them in a Profile, you will have to edit it manually.</p>
@@ -477,18 +479,20 @@ <h3 id="creating-a-status-menu-app">Creating a Status Menu app</h3>
477479
<p>Platypus-generated apps with <strong>Interface</strong> set to <strong>Status Menu</strong> show a Status Item in the menu bar when launched. When the item is pressed, a menu is opened, the script is executed and each line of output is shown as a menu item in the menu.</p>
478480
<p>When the user selects a menu item, the script is executed again, but this time it receives the menu title as an argument. Based on whether it receives an argument, the script can thus determine whether it is being invoked to list the menu items or in order to perform some action for a selected menu item.</p>
479481
<p>If this seems unclear, check out the following script, which is part of the MacbethMenu Example:</p>
480-
<pre><code>#!/usr/bin/perl
481-
482-
# If 0 arguments, we show menu
483-
if (!scalar(@ARGV)) {
484-
print &quot;Life&#39;s but a walking shadow, a poor player\n&quot;;
485-
print &quot;That struts and frets his hour upon the stage\n&quot;;
486-
print &quot;And then is heard no more.\n&quot;;
487-
} else {
488-
# We get the menu title as an argument
489-
system(&quot;/usr/bin/say \&quot;$ARGV[0]\&quot;&quot;);
490-
}
491-
</code></pre><p>This script creates a Status Menu app which shows a few lines from Shakespeare&#39;s Macbeth as menu items. When selected, the title of the menu item in question is fed into the macOS speech synthesizer via <code>/usr/bin/say</code>.</p>
482+
<div class="highlight"><pre><span class="c1">#!/usr/bin/perl</span>
483+
484+
<span class="c1"># If 0 arguments, we show menu</span>
485+
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nb">scalar</span><span class="p">(</span><span class="nv">@ARGV</span><span class="p">))</span> <span class="p">{</span>
486+
<span class="k">print</span> <span class="s">&quot;Life&#39;s but a walking shadow, a poor player\n&quot;</span><span class="p">;</span>
487+
<span class="k">print</span> <span class="s">&quot;That struts and frets his hour upon the stage\n&quot;</span><span class="p">;</span>
488+
<span class="k">print</span> <span class="s">&quot;And then is heard no more.\n&quot;</span><span class="p">;</span>
489+
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
490+
<span class="c1"># We get the menu title as an argument</span>
491+
<span class="nb">system</span><span class="p">(</span><span class="s">&quot;/usr/bin/say \&quot;$ARGV[0]\&quot;&quot;</span><span class="p">);</span>
492+
<span class="p">}</span>
493+
</pre></div>
494+
495+
<p>This script creates a Status Menu app which shows a few lines from Shakespeare&#39;s Macbeth as menu items. When selected, the title of the menu item in question is fed into the macOS speech synthesizer via <code>/usr/bin/say</code>.</p>
492496
<p><strong>Set icon for menu item</strong></p>
493497
<pre><code>MENUITEMICON|my_bundled_file.png|Bundled file example\n
494498
MENUITEMICON|/path/to/icon.png|Absolute path example\n
@@ -506,23 +510,25 @@ <h3 id="creating-a-status-menu-app">Creating a Status Menu app</h3>
506510
<pre><code>STATUSICON|bundled image filename or absolute path or URL\n
507511
</code></pre><h3 id="prompting-for-input-via-osascript-applescript">Prompting for input via osascript/AppleScript</h3>
508512
<p>Scripts can also prompt for input by running AppleScript code via the <code>/usr/bin/osascript</code> program. See an example in Perl below:</p>
509-
<pre><code>#!/usr/bin/perl
513+
<div class="highlight"><pre><span class="c1">#!/usr/bin/perl</span>
510514

511-
use strict;
515+
<span class="k">use</span> <span class="n">strict</span><span class="p">;</span>
512516

513-
sub osascript($) { system &#39;osascript&#39;, map { (&#39;-e&#39;, $_) } split(/\n/, $_[0]); }
517+
<span class="k">sub </span><span class="nf">osascript</span><span class="p">($)</span> <span class="p">{</span> <span class="nb">system</span> <span class="s">&#39;osascript&#39;</span><span class="p">,</span> <span class="nb">map</span> <span class="p">{</span> <span class="p">(</span><span class="s">&#39;-e&#39;</span><span class="p">,</span> <span class="nv">$_</span><span class="p">)</span> <span class="p">}</span> <span class="nb">split</span><span class="p">(</span><span class="sr">/\n/</span><span class="p">,</span> <span class="nv">$_</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span> <span class="p">}</span>
514518

515-
sub dialog {
516-
my ($text, $default) = @_;
517-
osascript(qq{
518-
tell app &quot;System Events&quot;
519-
text returned of (display dialog &quot;$text&quot; default answer &quot;$default&quot; buttons {&quot;OK&quot;} default button 1 with title &quot;Riddle&quot;)
520-
end tell
521-
});
522-
}
519+
<span class="k">sub </span><span class="nf">dialog</span> <span class="p">{</span>
520+
<span class="k">my</span> <span class="p">(</span><span class="nv">$text</span><span class="p">,</span> <span class="nv">$default</span><span class="p">)</span> <span class="o">=</span> <span class="nv">@_</span><span class="p">;</span>
521+
<span class="n">osascript</span><span class="p">(</span><span class="sx">qq{</span>
522+
<span class="sx"> tell app &quot;System Events&quot;</span>
523+
<span class="sx"> text returned of (display dialog &quot;$text&quot; default answer &quot;$default&quot; buttons {&quot;OK&quot;} default button 1 with title &quot;Riddle&quot;)</span>
524+
<span class="sx"> end tell</span>
525+
<span class="sx"> }</span><span class="p">);</span>
526+
<span class="p">}</span>
527+
528+
<span class="k">my</span> <span class="nv">$result</span> <span class="o">=</span> <span class="n">dialog</span><span class="p">(</span><span class="s">&quot;Answer to life, the universe and everything?&quot;</span><span class="p">,</span> <span class="s">&quot;42&quot;</span><span class="p">);</span>
529+
</pre></div>
523530

524-
my $result = dialog(&quot;Answer to life, the universe and everything?&quot;, &quot;42&quot;);
525-
</code></pre><p><a href="https://stackoverflow.com/questions/33601580/using-platypus-to-create-mac-os-x-applications-from-a-perl-script/33603239#33603239">Source.</a></p>
531+
<p><a href="https://stackoverflow.com/questions/33601580/using-platypus-to-create-mac-os-x-applications-from-a-perl-script/33603239#33603239">Source.</a></p>
526532
<h2 id="examples">Examples</h2>
527533
<h3 id="built-in-examples">Built-In Examples</h3>
528534
<p>Platypus includes many built-in examples. These can be opened via the <strong>Examples</strong> submenu of the <strong>Profiles</strong> menu. Brief explanation of each of the examples:</p>
@@ -566,25 +572,32 @@ <h3 id="built-in-examples">Built-In Examples</h3>
566572
<h2 id="updates">Updates</h2>
567573
<h3 id="updating-platypus">Updating Platypus</h3>
568574
<p>Platypus uses <a href="https://sparkle-project.org">Sparkle</a> for updates. You can update to the latest version by selecting <strong>Check for updates...</strong> in the application menu. Future releases may or may not break your saved profiles. Consult the version change log for details.</p>
569-
<p>The AppCast XML file is available <a href="https://sveinbjorn.org/files/appcasts/PlatypusAppcast.xml">here</a>.</p>
575+
<p>The AppCast XML feed is available <a href="https://sveinbjorn.org/files/appcasts/PlatypusAppcast.xml">here</a>.</p>
570576
<p>To get the absolutely latest development version of Platypus, you can check out the source repository on <a href="https://github.com/sveinbjornt/Platypus">GitHub</a>.</p>
571577
<h2 id="frequently-asked-questions">Frequently Asked Questions</h2>
572578
<h3 id="can-i-use-platypus-to-create-proprietary-software-">Can I use Platypus to create proprietary software?</h3>
573-
<p>Yes. Platypus is distributed under the terms and conditions of the three-clause <a href="https://sveinbjorn.org/files/software/platypus/documentation/License.html">BSD License</a>.</p>
579+
<p>Yes. Platypus is distributed under the terms and conditions of the three-clause <a href="https://sveinbjorn.org/files/software/platypus/documentation/License.html">BSD License</a>.
580+
Do what you want but keep my name out of it.</p>
574581
<h3 id="help-text-output-isn-t-being-shown-until-the-script-is-done-">Help, text output isn&#39;t being shown until the script is done!</h3>
575582
<p>You need to autoflush the output buffer. In Python, you can pass the <code>-u</code> parameter to the interpreter to get unbuffered output, or alternately flush the output buffer in code:</p>
576-
<pre><code>import sys
577-
sys.stdout.flush()
578-
</code></pre><p>In Perl, this is done with the following command at the start of your script:</p>
579-
<pre><code>$| = 1;
580-
</code></pre><p>For help with other scripting languages, <a href="https://stackoverflow.com">Stack Overflow</a> is your friend.</p>
583+
<div class="highlight"><pre><span class="kn">import</span> <span class="nn">sys</span>
584+
<span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
585+
</pre></div>
586+
587+
<p>In Perl, this is done with the following command at the start of your script:</p>
588+
<div class="highlight"><pre><span class="vg">$|</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
589+
</pre></div>
590+
591+
<p>Online search should be able to help you out with other scripting languages.</p>
581592
<h3 id="does-platypus-support-localizations-">Does Platypus support localizations?</h3>
582593
<p>No. But if you uncheck &quot;Optimize nib file&quot; in the save dialog when creating an app, the resulting nib in the application bundle can be edited using Xcode. You can thus localize your app manually if you want to. Support for localization is not on the feature roadmap.</p>
583594
<h3 id="how-does-my-script-access-the-user-s-shell-environment-e-g-path-">How does my script access the user&#39;s shell environment (e.g. PATH)?</h3>
584595
<p>Assuming that you&#39;re using <code>bash</code>, you can set the interpreter to <code>/bin/bash</code> and add the <code>-l</code> flag as an argument under &quot;Args&quot;. This makes <code>bash</code> act as if it had been invoked as a login shell. See <code>man bash</code> for details.</p>
585596
<p>Another alternative is to manually load the user&#39;s shell configuration file in your script:</p>
586-
<pre><code>source ~/.bashrc
587-
</code></pre><p>For other shells, consult their respective documentation.</p>
597+
<div class="highlight"><pre><span class="nb">source</span> ~/.bashrc
598+
</pre></div>
599+
600+
<p>For other shells, consult their respective documentation.</p>
588601
<h3 id="how-can-i-pass-specific-arguments-to-my-script-">How can I pass specific arguments to my script?</h3>
589602
<p>You can edit arguments to both the script interpreter and the script itself by pressing the <strong>Args</strong> button next to the <strong>Interpreter</strong> controls.</p>
590603
<h3 id="how-do-i-uninstall-platypus-">How do I uninstall Platypus?</h3>
@@ -596,10 +609,12 @@ <h3 id="how-do-i-get-the-source-code-to-platypus-and-platypus-generated-app-bina
596609
<h3 id="how-do-i-get-the-path-to-my-application-and-or-bundled-files-from-within-the-script-">How do I get the path to my application and/or bundled files from within the script?</h3>
597610
<p>The script executed by Platypus-generated applications runs from the Resources directory of the application bundle (e.g. <code>MyApp.app/Contents/Resources</code>). Any bundled files are thus accessible from the script&#39;s current working directory.</p>
598611
<p>For example, if you have added <code>file.txt</code> as a bundled file and want to copy it over to the user&#39;s home directory using a shell script, you would run the following command:</p>
599-
<pre><code>cp file.txt ~/
600-
</code></pre><p>To get the path to the application bundle itself, or its containing directory, you can use <code>../..</code> (application bundle) or <code>../../..</code> (application bundle&#39;s containing directory).</p>
612+
<div class="highlight"><pre>cp file.txt ~/
613+
</pre></div>
614+
615+
<p>To get the path to the application bundle itself, or its containing directory, you can use <code>../..</code> (application bundle) or <code>../../..</code> (application bundle&#39;s containing directory).</p>
601616
<h3 id="how-do-platypus-generated-applications-work-">How do Platypus-generated applications work?</h3>
602-
<p>Platypus-generated applications are macOS application (.app) <a href="https://en.wikipedia.org/wiki/Bundle_(OS_X">bundles</a>#OS_X_application_bundles), and have the following directory structure:</p>
617+
<p>Platypus-generated applications are macOS application (.app) <a href="https://en.wikipedia.org/wiki/Application_bundle">bundles</a>), and have the following directory structure:</p>
603618
<pre><code>MyApp.app/ Application bundle folder
604619
MyApp.app/Contents
605620
MyApp.app/Contents/Info.plist Info property list for app
@@ -622,12 +637,16 @@ <h3 id="can-i-prompt-for-user-input-via-stdin-in-my-platypus-wrapped-scripts-">C
622637
<h3 id="is-there-a-way-to-sign-platypus-generated-apps-so-they-don-t-require-gatekeeper-approval-">Is there a way to sign Platypus-generated apps so they don&#39;t require GateKeeper approval?</h3>
623638
<p>Platypus-generated apps are not signed by default. Due to GateKeeper, this means they will not run on macOS without prompting the user for approval. </p>
624639
<p>Platypus apps, like any other apps, can signed using the following command:</p>
625-
<pre><code>/usr/bin/codesign -s &quot;your-signing-identity&quot; path/to/MyApp.app
626-
</code></pre><p>See Apple&#39;s <a href="https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html">Code Signing Guide</a> for details.</p>
640+
<div class="highlight"><pre>/usr/bin/codesign -s <span class="s2">&quot;your-signing-identity&quot;</span> <span class="s2">&quot;path/to/MyApp.app&quot;</span>
641+
</pre></div>
642+
643+
<p>See Apple&#39;s <a href="https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html">Code Signing Guide</a> for details.</p>
627644
<h3 id="can-i-pass-arguments-to-a-platypus-generated-app-via-the-command-line-">Can I pass arguments to a Platypus-generated app via the command line?</h3>
628645
<p>Yes. You can execute a Platypus-generated binary via the command line. Any arguments you provide will be passed on to your script. Take the following example:</p>
629-
<pre><code># ./MyApp.app/Contents/MacOS/MyApp -arg1 -arg2
630-
</code></pre><p>In this case, both <code>-arg1</code> and <code>-arg2</code> will be passed on as arguments to your script. This feature makes it possible to create protocol handlers for Firefox and other programs that invoke macOS application binaries from the shell.</p>
646+
<div class="highlight"><pre>./MyApp.app/Contents/MacOS/MyApp -arg1 -arg2
647+
</pre></div>
648+
649+
<p>In this case, both <code>-arg1</code> and <code>-arg2</code> will be passed on as arguments to your script. This feature makes it possible to create protocol handlers for Firefox and other programs that invoke macOS application binaries from the shell.</p>
631650
<h3 id="where-is-the-command-line-tool-installed-">Where is the command line tool installed?</h3>
632651
<p>The Platypus command line tool install script creates the following files on your system:</p>
633652
<pre><code>/usr/local/bin/platypus Program binary
@@ -639,7 +658,7 @@ <h3 id="where-is-the-command-line-tool-installed-">Where is the command line too
639658
<h3 id="can-i-customize-the-about-window-of-a-platypus-generated-app-">Can I customize the About window of a Platypus-generated app?</h3>
640659
<p>If you add a file named <strong>Credits.rtf</strong> or <strong>Credits.html</strong> to the bundled files list, it will appear in the About window of your application.</p>
641660
<hr>
642-
<p>Copyright &copy; 2003-2025 <a href="mailto:sveinbjorn@sveinbjorn.org">Sveinbjorn Thordarson</a></p>
661+
<p>Copyright &copy; 2003-2025 <a href="mailto:sveinbjorn@sveinbjorn.org">Sveinbjorn Thordarson</a>.</p>
643662
</div>
644663
</div>
645664
</body>

0 commit comments

Comments
 (0)