Teamwork / node-auto-launch

Launch applications or executables at login (Mac, Windows, and Linux)
MIT License
941 stars 111 forks source link

How to handle the hidden in MacOS? #81

Open weiluenju opened 6 years ago

weiluenju commented 6 years ago

Now my program can auto start, but the window still show after login, even I already set isHidden to true.

I try to see the nw.App.argv array, but not found any about hidden information.

How can I do to handle the hidden in MacOS?

Thanks.

weiluenju commented 6 years ago

OK, I give up using the AppleScript,

I change to use the Launch Agent, but I found if i don't assign the path, the path in plist file will be

.../ABC.app/Contents/Versions/66.0.3359.117/nwjs Helper.app/Contents/MacOS/nwjs Helper

It is not work!

I need to assgin the path to

.../ABC.app/Contents/MacOS/nwjs

and then it is work.

BUT the filename of plist will be nwjs.plist.

It is very easy duplicate with other NW.js program.

Package NW.js by nw-builder

hedwigz commented 6 years ago

@weiluenju I also faced this problem.
I think they should really add this to the documentation.
Mac hidden handling is different from Linux and Windows.
What you need to do is check the LoginItemSettings:

const loginSettings = app.getLoginItemSettings();
const hidden = loginSettings.wasOpenedAsHidden;
adam-lynch commented 5 years ago

Please see that we're looking for contributors / maintainers: #64.

I'm happy to give access to people who are willing to help improve things, merge pull-requests, close issues, etc.