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

notifications: send the desktop file name with the notification #11913

Closed
wants to merge 1 commit into from
Closed

Conversation

tintou
Copy link

@tintou tintou commented Feb 13, 2018

I sadly haven't tested it.
It should allow any linux desktop environment to be able to know where the notification comes from and be able to categorize it in the settings and even be able to fine-tune per-app settings (play sound/show popup/keep in notification center).
How to test:
Build a linux app using notifications and test that the notification entry is present in the notification settings of the distribution (for example GNOME Control Center)

@tintou tintou requested a review from a team February 13, 2018 22:13
@welcome
Copy link

welcome bot commented Feb 13, 2018

💖 Thanks for opening this pull request! 💖

Here is a list of things that will help get it across the finish line:

  • Follow the JavaScript, C++, and Python coding style.
  • Run npm run lint locally to catch formatting errors earlier.
  • Document any user-facing changes you've made following the documentation styleguide.
  • Include tests when adding/changing behavior.
  • Include screenshots and animated GIFs whenever possible.
    We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can.

@tintou
Copy link
Author

tintou commented Feb 13, 2018

For instance, GNOME Shell is retrieving this information here https://gitlab.gnome.org/GNOME/gnome-shell/blob/master/js/ui/notificationDaemon.js#L189


libnotify_loader_.notify_notification_set_hint_string(
notification_, "desktop-entry", desktop_id.c_str());
}
Copy link
Member

@ckerr ckerr Feb 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't looked into this before, so some breadcrumbs on why this ought to work....

libgtkui::GetDesktopName() is implemented this way in chrome/browser/ui/libgtkui/gtk_util.cc:

std::string GetDesktopName(base::Environment* env) {
#if defined(GOOGLE_CHROME_BUILD)
  return "google-chrome.desktop";
#else  // CHROMIUM_BUILD
  // Allow $CHROME_DESKTOP to override the built-in value, so that development
  // versions can set themselves as the default without interfering with
  // non-official, packaged versions using the built-in value.
  std::string name;
  if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty())
    return name;
  return "chromium-browser.desktop";
#endif
}

and CHROME_DESKTOP is set by Electron apps:

void App::SetDesktopName(const std::string& desktop_name) {
#if defined(OS_LINUX)
  std::unique_ptr<base::Environment> env(base::Environment::Create());
  env->SetVar("CHROME_DESKTOP", desktop_name);
#endif
}

And, though it's probably common knowledge to people who might be reading this 😄 , desktop-entry is documented in this list of fdo hints at developer.gnome.org.

This specifies the name of the desktop filename representing the
calling program. This should be the same as the prefix used for the
application's .desktop file. An example would be "rhythmbox" from
"rhythmbox.desktop". This can be used by the daemon to retrieve the
correct icon for the application, for logging purposes, etc.

tl;dr: lgtm

@ckerr
Copy link
Member

ckerr commented Feb 19, 2018

I folded this into #11957, which fixes the 'name' argument passed to Notify and uses dbusmock to test.

@tintou thank you!

@tintou
Copy link
Author

tintou commented Feb 23, 2018

@ckerr Your branch is right, but splitting it into smaller-scope PR might at least allow some to be merged and thus increase the probability of getting this bug fixed ;)

@ckerr
Copy link
Member

ckerr commented Feb 23, 2018

Agreed, I ran short on time before the 2.0.0 freeze and wound up splitting the API breaking changes into a separate patch that didn't change the dbus traffic and so didn't need new dbus test scaffolding, and got than landed before the 2.0.0 freeze.

I'll get the rest of this landed Real Soon Now.

@ckerr ckerr mentioned this pull request Mar 9, 2018
@msudgh
Copy link

msudgh commented May 24, 2019

My notifications still are under Electron name. what should i set to have my application name?

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

Successfully merging this pull request may close these issues.

3 participants