Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Possible to add CLI arg to created shortcut? #8990

Open
Nantris opened this issue Mar 26, 2025 · 5 comments
Open

Possible to add CLI arg to created shortcut? #8990

Nantris opened this issue Mar 26, 2025 · 5 comments

Comments

@Nantris
Copy link

Nantris commented Mar 26, 2025

Example use case is that our app starts hidden with only a system tray icon upon startup, but when launched from the shortcut manually I'd like to have it appear visible.

@mmaietta
Copy link
Collaborator

This sounds like functionality that would need to be via electron APIs? I'm not sure how it could be implemented from our side. IIRC, we only pass CLI args to the installer during auto-update app restarts.

@Nantris
Copy link
Author

Nantris commented Mar 28, 2025

Thanks for your reply @mmaietta!

I'm not sure if I was clear enough - I implemented yargs on our end to handle a --start-visible flag, but there's no easy way to modify the shortcuts the installer makes on each platform to include that (and now that I think of it, I suppose this is primarily on Windows because I don't think the app launcher on macOS can even have custom args? And AppImage doesn't produce a shortcut to my knowledge)

In any case, I assume that's not something that could be finagled via the installer logic as it currently exists?

@mmaietta
Copy link
Collaborator

Looks like it may be possible to configure CreateShortCut, but I'm not familiar with the nsis CreateShortCut scripting command.
https://stackoverflow.com/questions/26804284/manage-shortcuts-arguments-for-nsis-createshortcut-method-via-cmake

https://github.com/search?q=repo%3Aelectron-userland%2Felectron-builder+CreateShortCut&type=code

Would you be willing to investigate that portion and get back to me? If args can be provided, then we can create a config property to allow those to be passed to the installer.nsh script

I suppose this is primarily on Windows because I don't think the app launcher on macOS can even have custom args? And AppImage doesn't produce a shortcut to my knowledge

This is correct.

@mmaietta
Copy link
Collaborator

Looks like it may be simple to add actually, but I'm really unequipped for nsis scripting.
https://nsis.sourceforge.io/Reference/CreateShortCut

@beyondkmp would you be willing to take a look at this when you have a chance?

@Nantris
Copy link
Author

Nantris commented Mar 28, 2025

A quick reading looks like the relevant part of the code to pass CLI args would be the first empty string below with the args:

CreateShortCut "$newStartMenuLink" "$appExe" "" "$appExe" 0 "" "" "${APP_DESCRIPTION}"

But unfortunately I know even less about NSIS myself so how to populate that is beyond me. This is a "nice-to-have" for us and I'm bogged down with bugs and stuff (and aren't all us coders?)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants