Skip to content

Commit e1d32bf

Browse files
committed
Make gtt a single instance application. closes kriskbx#14
1 parent 6d29299 commit e1d32bf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ app.on('window-all-closed', () => {
4848
// Fix transparency issues on Linux
4949
app.disableHardwareAcceleration();
5050

51+
// Single instance
52+
if(app.makeSingleInstance(() => {
53+
if (trayWindow) {
54+
trayWindow.show();
55+
trayWindow.focus();
56+
}
57+
})) {
58+
app.quit();
59+
process.exit();
60+
}
61+
5162
app.on('ready', () => {
5263
setTimeout(() => {
5364
gtt._dump('Running on ' + gtt._platform);
@@ -563,7 +574,10 @@ process.on('uncaughtException', function (e) {
563574
Raven.config('https://[email protected]/1218774').install();
564575
Raven.captureException(e);
565576
console.log("done.");
566-
setTimeout(process.exit, 5000);
577+
setTimeout(() => {
578+
app.quit();
579+
process.exit();
580+
}, 5000);
567581
return;
568582
}
569583

0 commit comments

Comments
 (0)