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

Google Chrome: It's better to return ("body", "actions") from GetCapabilities() #12

Open
minoru-chikamune opened this issue Jan 2, 2021 · 0 comments

Comments

@minoru-chikamune
Copy link

trdr; Google Chrome requires "body" and "actions" capabilities. So it's better to return ("body", "actions") from GetCapabilities().

I love statnot because I can create my scripts to control notifications. In my case, most of the notification comes from Google Chrome. So I'm using statnot to receive notifications from Google Chrome. But I had to modify the original source code a little bit.

[How to setup / reproduce]

Google Chrome checks these two things.

  • Checks if "org.freedesktop.Notifications" is "activatable" or not.
  • Checks if GetCapabilities() returns "body" and "actions".

So I had to do these steps to use statnot to receive notifications from Google Chrome.

1. Make statnot "activatable"

Create a file here.

~/.local/share/dbus-1/services/org.freedesktop.Notifications.service

The contents need to be below. Please modify the shell script as you like.

[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=~/.bin/my-notification-daemon.sh

My shell script looks like below.

#!/bin/bash
exec python3 -u ~/.app/statnot/statnot ~/.app/statnot/statnot_config.py &

Now, dbus can activate statnot if there is no statnot process. And Google Chrome requires this. As you can see on the chrome's code [Ref:1], Google Chrome uses "ListActivatableNames". This is presumably because this is a more reliable way. If the statnot process dies, it will be automatically restarted.

2. Modify statnot's GetCapabilities function to return "body" and "actions"

Google Chrome requires "body" and "actions" capabilities at minimum [Ref:2]. So I had to modify statnot's GetCapabilities function like below.

    @dbus.service.method("org.freedesktop.Notifications", in_signature='', out_signature='as')
    def GetCapabilities(self):
        return ("body", "actions")

3. Launch Google Chrome with options

This is my script to launch Google Chrome. I had to launch Google Chrome via dbus-launch (or we can use export $(dbus-launch)). And also we need to enable native notifications flag (this can be set via chrome://flags/#enable-native-notifications).

#!/bin/bash
# export $(dbus-launch)
exec dbus-launch google-chrome --enable-features=NativeNotifications $@ &

In summary, my request is to return ("body", "actions") from GetCapabilities(). But it's OK for now because I just need to modify the original statnot code a bit.
Thank you for creating statnot.

[Ref:1]
https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/notifications/notification_platform_bridge_linux.cc;l=67?q=ListActivatableNames
[Ref:2]
https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/notifications/notification_platform_bridge_linux.cc;l=491

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

1 participant