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

Use xdg-desktop-portal for Notification inside Flatpak #680

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

JakobDev
Copy link
Contributor

When running a Program inside a Flatpak, you have no access to org.freedesktop.Notifications unless you allow it explicit. The notify-send binary is also not available.

This PR adds support for the Notification API of the xdg-desktop-portal API, so it works out of the box inside Flatpaks.

I use the gdbus binary, because dbus-python is not in the requirements of player and not included in the Flatpak Runtimes. When installing a Python package, that has plyer in it's requirements, dbus-python will not automagically be installed with plyer, what gives Flatpak users a not working package. gdbus however is included in all Runtimes and will work without any Problems.

Just a tip for the Developers:
Some Portals (not all) like the FileChooser Portal can also be used outside Flatpaks. This might be better way to implement things like the FileChooser function than using things like zenity or kdialog.

Copy link
Member

@tshirtman tshirtman left a comment

Choose a reason for hiding this comment

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

I did not test it, but looks good to me, thanks for the context explanation.

@JakobDev
Copy link
Contributor Author

I did not test it, but looks good to me, thanks for the context explanation.

Here's a short description how to test it: Create a epty directory. Enter the directory and clone the repo (or my Fork in this case). Create a textfile named com.github.kivy.plyer.yml. Your directory should look like this:

plyer (directory)
com.github.kivy.plyer.yml (file)

com.github.kivy.plyer.yml should have this content:

app-id: com.github.kivy.plyer
runtime: org.freedesktop.Platform
runtime-version: "21.08"
sdk: org.freedesktop.Sdk
command: /usr/bin/python
finish-args:
  - --socket=fallback-x11
  - --socket=wayland
  - --share=network
  - --device=dri
  - --share=ipc

modules:
  - name: plyer
    buildsystem: simple
    build-commands:
      - pip3 install --no-deps --no-use-pep517 --prefix=$FLATPAK_DEST .
    sources:
      - type: dir
        path: plyer

Now open a shell in the Directory and enter this command to build:
flatpak-builder --user --install --force-clean build-dir com.github.kivy.plyer.yml

Now use this command to run it:
flatpak run com.github.kivy.plyer

It opens the Python REPL inside the Flatpak. Now you can test around. If you make changes to plyer, repeat the 2 commands.

@akshayaurora akshayaurora merged commit 06c7f9d into kivy:master Jul 5, 2022
@JakobDev JakobDev deleted the notificationportal branch July 5, 2022 16:25
@misl6 misl6 mentioned this pull request Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants