Quickly shutdown, reboot, log off, halt, your computer using the native shutdown command easily from an electron app. Cross platform (macOS; Windows and Linux)
I don't know if this project is still maintained, but I am going to ask my question anyways.
When starting the project with npm or yarn I am able to use every single command you offer. However, when packaged something seems odd. Every shutdown I tried just creates a new instance of the application. Some kind of security is in my way, created both by electron-packager oder electron-builder. Even calling a batch or c++ executable doesn't seem to change the problem.
I am running the newest version of electron and the packagers on windows 10.
setTimer returns an array of arguments which is then pushed into the arguments in the enclosing command's function. This produces an array of arguments like so: ['shutdown', ['-t 0']]. In this implementation there is only one argument added in the setTimer function but if there were more than one it would result in a comma added between the arguments.
The code in it's current form throws an error when evaluated by TypeScript.
When I'm logging process.platform it results in win32, but I'm still unable to run your abort-function.
The solution would be to change the condition of the first if-statement at the abort-function at line 101
I was looking for cross platform shutdown npm package and found yours. It seems to be working nice so kudos to you!
The problem is that my project has nothing to do with Electron so I don't want to use it and download unnecessary packages.
What do you think about extracting the core "shutdown/hibernate/sleep/etc" logic into the separate package and publish it as a new npm? I can do it too but I just didn't want to basically take your entire code and publish it as mine package.
Hi, @samuelcarreira . Firstly, thanks for your work in this lib!!
I was trying to schedule a shutdown. Since all of the existent SO permit this function, this could be a an relevant feature for the lib.
Right now I'm just calculating the interval from current time to the shutdown point, but a more direct approach would be to just pass the time you want to shutdown.
If you think that this feature is relevant for the project I could help with tests or taking a look and submitting a PR.
I get a TypeError: Cannot read property 'sudo' of undefined on index.js:118. This is caused by calling reboot() without an argument on Linux. I suggest to provide a default {} value for the argument to avoid this.