Right now I'am using npm start to open a desktop app (i.e nodejs server) which uses electron framework. So when ever I want to open that desktop app I have to open the terminal, go the application directory and use command "npm start" to open the nodejs server i.e desktop app.

I want to write a python scrip to create a desktop app, and when ever I double click that desktop icon, it should internally uses 'npm start' command to open that desktop app.

Can any one please help me, and my application directory is as: /Desktop/Electron/charityapp.

3 Answers 3

  • Open Terminal
  • cd ~/Desktop
  • echo '#!/bin/sh' > run-my-app
  • echo 'cd ~/Desktop/Electron/charityapp' >> run-my-app
  • echo 'npm start' >> run-my-app
  • chmod +x run-my-app

Then just double-click on the icon on the Desktop


Just an addition to the other answer:
if you wouldn't like to see a terminal window opening up each time you double click the bash script file you could create an Automator bundle.

  1. After opening my favorite option are create an application or a service (you can later bind a shortcut to this)
  2. Then select, Library → Utilities and double click on Run Shell Script
  3. From there, in a couple of my previous I used this setting Services recives: no input in: any applications
  4. In the Shell option you can choose /bin/bash instead of the in-script #!/bin/sh and then add the lines of scripts:

    cd ~/Desktop/Electron/charityapp     
    npm start

  • You could even choose python script here, but in this case I don't know how to help you.

  • For a shortcut after saving the you-service-name can be seen in System Preferences → Keyboard → Shortcuts → Services.


Open textedit & paste it:

#!/usr/bin/env python
import os

def main():
    os.system("npm start")

if __name__ == '__main__':

Save it, remove its extension (using Finder is okay) & run

chmod +x /Users/ankii/Desktop/testapp

Python script executable opened by text editor

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .