Issue
This is a Electron Application for linux.
main.js
const electron = require("electron");
const app = electron.app;
const browserWindow = electron.BrowserWindow;
const path = require("path");
const url = require("url");
let win;
function createWindow() {
win = new browserWindow({width: 800, height: 600});
win.loadURL(url.format({
pathname : path.join(__dirname,"index.html"),
protocol : "file",
slashes : true ,
}));
win.on("closed", () => {win = null;})
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if(prcess.platform !== "darwin")
app.quit()
});
app.on ("activate", ()=> {
if(win == null)
createWindow()
});
i start the app in linux by npm start
.
Problems :
i) how to auto start it at bootup?
ii) which part of the code is to implement?
Solution
To autorun a file in linux on session started, create a desktop entry file (fileName.desktop)
[Desktop Entry]
Name= app_name
Comment= comment_optional
Icon= app_icon
Exec= your file path
Terminal=false
Type=Application
save it in either /.config/autostart/
or /etc/xdg/autostart/
then the file will run automatically on system bootup.
Answered By - vishal Answer Checked By - David Marino (WPSolving Volunteer)