title: How can I make a Platypus-created shell application respond to a keyboard command?
body: <p>Using Platypus, I created a simple application which runs the following shell script:</p>
  
  <pre><code>    cd
      if [ -e /Applications/Music.app/Contents/Resources/Music.py ]; then
        export PATH=$PATH:/Applications/Music.app/Contents/Resources
        cd "/Applications/Music.app/Contents/Resources"
        EXTENSION=`osascript -e 'tell application (path to frontmost application as text) to display dialog "Do you want to enable extensions during this session?" buttons {"Yes", "No"} with  icon file "Applications:Music.app:Contents:Resources:alert.icns"'`
        if [ "$EXTENSION" == "button returned:Yes" ]; then
          python Music.py arg1 &gt;&gt; music.txt &amp;
        else
          python Music.py arg2 &gt;&gt; music.txt &amp;
        fi
      else
        osascript -e 'tell application (path to frontmost application as text) to display dialog "Please move this application into your native applications folder (/Applications)." buttons {"OK"} with icon stop'
        osascript -e 'quit app "Music.app"'
      fi
  </code></pre>
  
  <p>The "Music.py" script runs in an infinite loop, constantly selecting one of about 80 URLs to load on Selenium using chromedriver.  Each URL loads a particular song, and, when the song is finished playing, the Python script randomly selects another position on the array of possible song URLs and loads the corresponding song (so it basically shuffles through a given playlist).</p>
  
  <p>The playback can be paused using the <code>kill -STOP [pid]</code> and resumed using the <code>kill -CONT [pid]</code> commands.  However, I want to be able to pause it by clicking on the "Music.app" icon on my Mac's dock (to bring this application to the foreground and ensures that it receives all keystrokes) and using a keyboard shortcut.</p>
  
  <p>After some experimenting, I found that by running the commands:</p>
  
  <pre><code>   bind '"^P":"ID_PARENT=`pgrep chromedriver` &amp;&amp; ID_CHILD=`pgrep -P $ID_PARENT` &amp;&amp; echo $ID_CHILD &amp;&amp; kill -STOP $ID_CHILD\n"'
     bind '"^R":"ID_PARENT=`pgrep chromedriver` &amp;&amp; ID_CHILD=`pgrep -P $ID_PARENT` &amp;&amp; echo $ID_CHILD &amp;&amp; kill -CONT $ID_CHILD\n"'      
  </code></pre>
  
  <p>in my normal command line, I am able to pause and resume the process using Ctrl + P and Ctrl + R, respectively.  However, when I added these lines at the beginning of the shell script, the keyboard shortcut still did not do anything in the application (the keystrokes were not actually registered within the shell script).  Though I can pause/play the music with my default command line, my goal is to create a user-friendly and completely portable application, and I would prefer if the user could completely manipulate the program without having to interact with anything but the app itself.</p>
  
  <p>So, my question is, how can I add these keyboard shortcuts to the application itself (which was created by Platypus.app and essentially just runs a shell script)?  I'm using MacOS High Sierra 10.3.5, if that matters.  I'm definitely new to programming in general, am not overly experienced with shell, and have never used Platypus.app before, so I'm unfamiliar with this and don't know if what I want is actually possible.  Any help is appreciated.</p>
  
  <p>Thanks!</p>