Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Implement MPRIS Raise method to allow showing the window #1845

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/main/base/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class AppEvents {
this.tray.setToolTip(app.getName());
this.setTray(false);

this.tray.on("double-click", () => {
this.tray.on("double-click", () => { // supports windows and mac only
if (utils.getWindow()) {
if (utils.getWindow().isVisible()) {
utils.getWindow().focus();
Expand All @@ -290,6 +290,16 @@ export class AppEvents {
}
});

this.tray.on("click", () => {
if (utils.getWindow() && process.platform === "linux") { // use single click to open when double doesn't work
if (utils.getWindow().isVisible()) {
utils.getWindow().focus();
} else {
utils.getWindow().show();
}
}
});

utils.getWindow().on("show", () => {
this.setTray(true);
});
Expand Down
4 changes: 4 additions & 0 deletions src/main/plugins/mpris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export default class mpris {
player.on("volume", (volume: string) => {
renderer.executeJavaScript(`app.mk.volume = ${parseFloat(volume)}`);
});
player.on("raise", () => {
mpris.utils.getWindow().show();
mpris.utils.getWindow().focus();
});

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