Skip to content

Commit 6edc94a

Browse files
authored
Merge pull request #941 from Araxeus/fix-snoretoast
fix SnoreToast implementation
2 parents 98e677a + e614694 commit 6edc94a

File tree

4 files changed

+12
-88
lines changed

4 files changed

+12
-88
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -38,60 +38,6 @@ jobs:
3838
- name: Install dependencies
3939
run: yarn --frozen-lockfile
4040

41-
######################
42-
# Patch SnoreToast to fix App ID - see https://github.com/th-ch/youtube-music/issues/479#issuecomment-965473559
43-
- name: SnoreToast - parameters
44-
id: snoretoast-params
45-
if: startsWith(matrix.os, 'windows')
46-
shell: bash
47-
run: |
48-
echo "::set-output name=version::v0.8.0"
49-
echo "::set-output name=path::./vendor/snoretoast"
50-
51-
- name: SnoreToast - cache
52-
id: snoretoast-cache
53-
uses: actions/cache@v2
54-
if: startsWith(matrix.os, 'windows')
55-
with:
56-
path: ${{ steps.snoretoast-params.outputs.path }}
57-
key: snoretoast-${{ steps.snoretoast-params.outputs.version }}
58-
59-
- name: SnoreToast - compile
60-
if: |
61-
startsWith(matrix.os, 'windows') &&
62-
steps.snoretoast-cache.outputs.cache-hit != 'true'
63-
shell: bash
64-
run: |
65-
SNORETOAST_TAG="${{ steps.snoretoast-params.outputs.version }}"
66-
echo "Compiling SnoreToast $SNORETOAST_TAG"
67-
68-
git config --global user.email "th-ch@users.noreply.github.com"
69-
git config --global user.name "YouTube Music"
70-
git clone -c advice.detachedHead=false --branch $SNORETOAST_TAG --depth 1 https://github.com/KDE/snoretoast.git ${{ steps.snoretoast-params.outputs.path }}
71-
cd ${{ steps.snoretoast-params.outputs.path }}
72-
73-
# Apply https://github.com/KDE/snoretoast/pull/15/commits/c5faeceaf36f4b9fb27e5269990b716a25ecbe43
74-
# Patch generated with `git format-patch -1 c5faeceaf36f4b9fb27e5269990b716a25ecbe43`
75-
git am < ../snoretoast-patch/0001-Fix-activation-not-writing-to-pipe.patch
76-
77-
# Compile for win32
78-
cmake -A Win32 -B build32
79-
cmake --build build32 --config Release
80-
81-
# Compile for x64
82-
cmake -A x64 -B build64
83-
cmake --build build64 --config Release
84-
85-
- name: SnoreToast - overwrite with custom build
86-
if: startsWith(matrix.os, 'windows')
87-
shell: bash
88-
run: |
89-
# Override SnoreToast with the patched versions
90-
cp ${{ steps.snoretoast-params.outputs.path }}/build32/bin/Release/snoretoast.exe ./node_modules/node-notifier/vendor/snoreToast/snoretoast-x86.exe
91-
cp ${{ steps.snoretoast-params.outputs.path }}/build64/bin/Release/snoretoast.exe ./node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe
92-
# End of SnoreToast patch
93-
######################
94-
9541
- name: Test
9642
uses: GabrielBB/xvfb-action@v1
9743
env:

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ app.on("ready", () => {
363363

364364
// Register appID on windows
365365
if (is.windows()) {
366+
// Depends on SnoreToast version https://github.com/KDE/snoretoast/blob/master/CMakeLists.txt#L5
367+
const toastActivatorClsid = "eb1fdd5b-8f70-4b5a-b230-998a2dc19303";
368+
366369
const appID = "com.github.th-ch.youtube-music";
367370
app.setAppUserModelId(appID);
368371
const appLocation = process.execPath;
@@ -372,7 +375,11 @@ app.on("ready", () => {
372375
const shortcutPath = path.join(appData, "Microsoft", "Windows", "Start Menu", "Programs", "YouTube Music.lnk");
373376
try { // check if shortcut is registered and valid
374377
const shortcutDetails = electron.shell.readShortcutLink(shortcutPath); // throw error if doesn't exist yet
375-
if (shortcutDetails.target !== appLocation || shortcutDetails.appUserModelId !== appID) {
378+
if (
379+
shortcutDetails.target !== appLocation ||
380+
shortcutDetails.appUserModelId !== appID ||
381+
shortcutDetails.toastActivatorClsid !== toastActivatorClsid
382+
) {
376383
throw "needUpdate";
377384
}
378385
} catch (error) { // if not valid -> Register shortcut
@@ -381,9 +388,10 @@ app.on("ready", () => {
381388
error === "needUpdate" ? "update" : "create",
382389
{
383390
target: appLocation,
384-
cwd: appLocation.slice(0, appLocation.lastIndexOf(path.sep)),
391+
cwd: path.dirname(appLocation),
385392
description: "YouTube Music Desktop App - including custom plugins",
386-
appUserModelId: appID
393+
appUserModelId: appID,
394+
toastActivatorClsid
387395
}
388396
);
389397
}

plugins/notifications/interactive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function sendToaster(songInfo) {
5151
//download image and get path
5252
let imgSrc = notificationImage(songInfo, true);
5353
toDelete = {
54-
appID: is.dev() ? undefined : "com.github.th-ch.youtube-music",
54+
appID: "com.github.th-ch.youtube-music",
5555
title: songInfo.title || "Playing",
5656
message: songInfo.artist,
5757
id: parseInt(Math.random() * 1000000, 10),

vendor/snoretoast-patch/0001-Fix-activation-not-writing-to-pipe.patch

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)