简体   繁体   中英

how to set command line for electron

I need a the electron start with transparent window in linux, the documents say I need put --enable-transparent-visuals --disable-gpu in the command line. Is there a way to pass the command line args in the program not in the terminal command line. like this:

electron . --enable-transparent-visuals --disable-gpu

I need when I run

electron .

the args have set in the program.It means I just double click the bin file and the args are OK. Don't need to pass them manually.

You can put them in the main script of the application (main.js), before the 'ready' event of the app module is emitted, like so:

const electron = require('electron')
// Module to control application life.
const app = electron.app
app.commandLine.appendSwitch('enable-transparent-visuals');
app.commandLine.appendSwitch('disable-gpu');

app.on('ready', () => {
  // Your code here
});

For a list of other command line switches, you can go here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM