const fs = require('fs'); const mkdirp = require('mkdirp'); const { join, basename, dirname } = require('path'); const { app } = require('electron'); const buildInfo = require('../utils/buildInfo'); const desktopPath = join(app.getPath('appData'), 'autostart', app.name + '-' + buildInfo.releaseChannel + '.desktop'); // Vars for use in desktop file content template const exec = app.getPath('exe'); // Template for desktop file const desktopContent = `[Desktop Entry] Type=Application Exec=${exec} Hidden=false NoDisplay=false Name=${basename(process.execPath)} Icon=${join(global.systemElectron ? '/usr/share/pixmaps/Discord' : dirname(exec), 'discord.png')} Comment=Text and voice chat for gamers. X-GNOME-Autostart-enabled=true`; exports.install = (cb) => { try { mkdirp.sync(dirname(desktopPath)); return fs.writeFile(desktopPath, desktopContent, cb); } catch { return cb(); // Callback anyway } }; exports.update = (cb) => cb(); exports.uninstall = (cb) => fs.unlink(desktopPath, cb); exports.isInstalled = (cb) => fs.access(desktopPath, fs.constants.F_OK, cb);