NW.js SDK macOS build - override the default page shown / directory path

Skip to first unread message

Tomáš Hübelbauer

Jul 31, 2021, 4:31:19 AM7/31/21
to nw.js

Hello! I am using NW.js with the SDK build and during development, I do the recommended
nwjs-sdk-v0.54.1-osx-x64/nwjs.app/Contents/MacOS/nwjs . from the directory where my source code is. This works just fine, NW.js loads my app.

However, I would also like to be able to pin the development version into the macOS Dock and launch it using the Dock icon. When I pin the window that is opened the above way and then start it using the Dock icon, it shows the default page as if I ran it just using
nwjs-sdk-v0.54.1-osx-x64/nwjs.app/Contents/MacOS/nwjs without the dot for the current source code directory - which I assume is actually exactly what is happening "behind the scenes" when pinning to the Dock - only the executable path is stored but not the command line arguments.

I know I can bundle my application and that way it will have all the resources embedded within it and start up to my application. However, I would like to be able to Dock the development version (so that I can sometimes develop, sometimes just use the app with the latest source code).

I looked into adding command line arguments to Dock items and it seems like it is not possible. Maybe I could pin a shell script that starts NW.js in my source code directory? Does anyone have experience with that? Or - is it possible to patch the `nwjs` SDK downloaded binary such that instead of loading the default page, it loads a given page at some path I specify? I think this would work too, but I am not sure if the default page path is baked into the executable or if there is some config I can adjust to make it load something else?

Thank you

Tomáš Hübelbauer

Jul 31, 2021, 10:30:49 AM7/31/21
to nw.js
For now I've settled to using an Automator Application-type script which has a single step: Run Shell Script. The script cd-s into my application directory and runs the nwjs app with the correct current-directory argument. I've saved and pinned the application to dock and it works correctly. It is even possible to set the Automator Application icon by going to the Get Info modal in Finder and just pasting an image onto the existing default icon. However, when opening the application from the Dock this way, a new NW window icon will show up in the Dock and have the black dot underneath indicating a running application; the Automator Application itself only acts as a shortcut. This is understandable, but undesirable to me, so I am still interested in whether it is possible to tell the NW.js binary to load a different page from the default one.
Reply all
Reply to author
0 new messages