Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification not showing on Linux when a title is provided #69

Closed
naholyr opened this issue Dec 21, 2017 · 4 comments
Closed

Notification not showing on Linux when a title is provided #69

naholyr opened this issue Dec 21, 2017 · 4 comments

Comments

@naholyr
Copy link

naholyr commented Dec 21, 2017

The issue

When using mocha --growl on my Linux distribution using notify-send, notifications do not appear.

I've looked into the executed command, and it tries to run notify-send '-i' '/…/node_modules/mocha/images/ok.png' '--hint=int:transient:1' 'Passed' '' '4 tests passed in 1236ms' which, when run directly into my terminal, responds with Invalid number of options. The empty string in the middle got my attention, and it seems to be actually the cause of this bug as it works fine without it.

The solution?

In the code I find those lines:

		case 'Linux':
			if (options.title) {
				args.push(options.title)
				args.push(cmd.msg)
				args.push(msg.replace(/\\n/g, '\n'))
			} else {
				args.push(msg.replace(/\\n/g, '\n'))
			}

I don't get why cmd.msg AND msg.replace(…) are both added while notify-send only takes one body argument (see below). It works fine when I remove args.push(cmd.msg), which is my proposed solution (but there may be side-effects?).

Environment information

notify-send --version

notify-send 0.7.6

lsb_release -a

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial

notify-send --help

Usage:
  notify-send [OPTION...] <SUMMARY> [BODY] - create a notification

Help Options:
  -?, --help                        Show help options

Application Options:
  -u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).
  -t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.
  -a, --app-name=APP_NAME           Specifies the app name for the icon
  -i, --icon=ICON[,ICON...]         Specifies an icon filename or stock icon to display.
  -c, --category=TYPE[,TYPE...]     Specifies the notification category.
  -h, --hint=TYPE:NAME:VALUE        Specifies basic extra data to pass. Valid types are int, double, string and byte.
  -v, --version                     Version of the package.
@naholyr
Copy link
Author

naholyr commented Dec 21, 2017

Additional info about environment

dpkg -S notify-send

libnotify-bin: /usr/bin/notify-send
libnotify-bin: /usr/share/man/man1/notify-send.1.gz

dpkg -s libnotify-bin

Package: libnotify-bin
Status: install ok installed
Priority: optional
Section: utils
Installed-Size: 69
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: libnotify
Version: 0.7.6-2svn1
Depends: libc6 (>= 2.3.4), libglib2.0-0 (>= 2.26), libnotify4 (>= 0.7.3)
Description: sends desktop notifications to a notification daemon (Utilities)
 A library that sends desktop notifications to a notification daemon, as
 defined in the Desktop Notifications spec. These notifications can be
 used to inform the user about an event or display some form of
 information without getting in the user's way.
 .
 This package contains the binary which sends the notification.
Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>

@hmshwt
Copy link
Contributor

hmshwt commented Jan 18, 2018

@naholyr I am facing the same issue while using node-growl with Mocha on

Ubuntu 17.10
notify-send version 0.7.7
libnotify-bin version 0.7.7-2.

I confirm that notify-send responds with 'Invalid number of options' because of an extra argument '' inserted by cmd.msg . I would like to send a PR.

@deiga
Copy link
Collaborator

deiga commented Jan 18, 2018

@hmshwt Feel free to make a PR

deiga pushed a commit that referenced this issue Jan 28, 2018
* Remove cmd.msg from args when using notify-send

Fixes Issue#69 #69

On linux notify-send responds with 'Invalid number of options' because of an extra empty '' argument introduced by cmd.msg

* Fix options.sticky argument when using notify-send

When using the sticky option with notify-send, it interprets '-t 0' as a single argument. To resolve that '-t' and '0' are sent as separate arguments.
- Executing the following command
"notify-send '-t 0' 'Email Client' '5 new emails' "
- results in
"Cannot parse integer value “Email Client” for -t"

* Log cmd and args to stderr for easier debugging
@deiga
Copy link
Collaborator

deiga commented Jan 29, 2018

Fixed in 1.10.4

@deiga deiga closed this as completed Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants