mikaelbr / node-notifier

A Node.js module for sending notifications on native Mac, Windows and Linux (or Growl as fallback)
MIT License
5.72k stars 323 forks source link

node-notifier not working in wsl2 #400

Open wbern opened 2 years ago

wbern commented 2 years ago

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 commented 2 years ago

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

wbern commented 2 years ago

This is what I get back as result using wsl2

image

stsourlidakis commented 2 years ago

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 commented 2 years ago

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.

JimmayVV commented 2 years ago

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.

orgrimarr commented 1 year ago

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' }
  );
}