Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit e814b13

Browse files
authored
Implement MPRIS Raise method to allow showing the window (#1845)
* add functionality to raise window on mpris method call * since electron tray doesn't support double click on linux, open on single click there
1 parent b1d0f69 commit e814b13

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/base/app.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class AppEvents {
281281
this.tray.setToolTip(app.getName());
282282
this.setTray(false);
283283

284-
this.tray.on("double-click", () => {
284+
this.tray.on("double-click", () => { // supports windows and mac only
285285
if (utils.getWindow()) {
286286
if (utils.getWindow().isVisible()) {
287287
utils.getWindow().focus();
@@ -291,6 +291,16 @@ export class AppEvents {
291291
}
292292
});
293293

294+
this.tray.on("click", () => {
295+
if (utils.getWindow() && process.platform === "linux") { // use single click to open when double doesn't work
296+
if (utils.getWindow().isVisible()) {
297+
utils.getWindow().focus();
298+
} else {
299+
utils.getWindow().show();
300+
}
301+
}
302+
});
303+
294304
utils.getWindow().on("show", () => {
295305
this.setTray(true);
296306
});

src/main/plugins/mpris.ts

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ export default class mpris {
7373
player.on("volume", (volume: string) => {
7474
renderer.executeJavaScript(`app.mk.volume = ${parseFloat(volume)}`);
7575
});
76+
player.on("raise", () => {
77+
mpris.utils.getWindow().show();
78+
mpris.utils.getWindow().focus();
79+
});
7680

7781
mpris.utils.getIPCMain().on("mpris:playbackTimeDidChange", (event: any, time: number) => {
7882
player.getPosition = () => time;

0 commit comments

Comments
 (0)