node-notifier icon indicating copy to clipboard operation
node-notifier copied to clipboard

node-notifier not working in wsl2

Open wbern opened this issue 2 years ago • 6 comments

Hey!

I'm using wsl2 Ubuntu and integrated terminal with vscode and windows 10.

I don't get any errors but it seems I don't get any notifications? I couldn't find and previous issues about this, but is there something I need to set up? I've got the DISPLAY variable assigned to my local ip:0.0 as well.

I'm using it like this.

import notifier from "node-notifier"

notifier.notify({
  title: 'My notification',
  message: 'Hello, there!'
});

Thanks in advance.

wbern avatar Mar 01 '22 18:03 wbern

I just tried using powershell and it doesn't seem to work either.

wbern avatar Mar 01 '22 19:03 wbern

This is what I get back as result using wsl2

image

wbern avatar Mar 01 '22 19:03 wbern

Hello I have the same issue, it seems that the problem only occurs when the package is installed under the WSL2 file system. If the package is installed under the Windows file system (/mnt/c/...) and you try to use it in WSL2, the notifications work as expected.

Steps to reproduce: Open a WSL2 window

cd ~
mkdir test-node-notifier
cd test-node-notifier
npm i node-notifier
node
> const notifier = require("node-notifier");
> notifier.notify({ title: "Hey", message: "Hello" });

If you run the reproduction steps in a Windows path (e.g. under /mnt/c/Users/<your-username>/) you will get the notification without issues.

Note: If I manually chmod +x on snoreToast/snoretoast-x*.exe (as per #353) the issue is fixed.

Thank you for your time.

stsourlidakis avatar Apr 26 '22 22:04 stsourlidakis

This will probably be fixed if the permissions for the 2 binaries are updated (chmod +x) and committed again. I can open a pull request if you agree @mikaelbr.

stsourlidakis avatar Apr 27 '22 17:04 stsourlidakis

WSL2 support via the binaries would be wonderful. I do understand there's a workaround to manually apply the execution bit, but a fix targeting WSL compatibility would be a huge win for Windows users.

JimmayVV avatar Jun 16 '22 00:06 JimmayVV

It's working using WindowsBalloon on my installation (WSL ubuntu on W11)

Maybe switch WindowsToaster to WindowsBalloon for WSL installtion or use WindowsBalloon as a fallback ?

import isWsl from "is-wsl";
import notifier from "node-notifier";
if (isWsl) {
  new notifier.WindowsBalloon({}).notify(
    { title: 'WindowsBalloon', message: 'Hello from WSL using WindowsBalloon' }
  );
}

orgrimarr avatar Jun 12 '23 10:06 orgrimarr