Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/auto-launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ function getDesktopFile () {
return path.join(untildify('~/.config/autostart/'), 'ipfs-desktop.desktop')
}

function quoteDesktopEntryArg (value) {
return `"${value.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`
}

function getLinuxAutostartExec () {
const command = [process.execPath]

// Some distro packages launch as `electron <app.asar>`.
if (path.basename(process.execPath).startsWith('electron')) {
const appPath = app.getAppPath()

if (appPath && appPath !== process.execPath) {
command.push(appPath)
}
}

return command.map(quoteDesktopEntryArg).join(' ')
}

async function enable () {
if (app.setLoginItemSettings && (IS_MAC || IS_WIN)) {
app.setLoginItemSettings({ openAtLogin: true })
Expand All @@ -32,7 +51,7 @@ Type=Application
Version=1.0
Name=IPFS Desktop
Comment=IPFS Desktop Startup Script
Exec="${process.execPath}"
Exec=${getLinuxAutostartExec()}
Icon=ipfs-desktop
StartupNotify=false
Terminal=false`
Expand Down