Use xdg-desktop-portal for Image.grab() on Linux
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- linux, python
- Domaine
- desktop, operating-systems
Piste de recherche
Start at the Image.grab() entry point and read the xdg-desktop-portal Screenshot API linked in the issue. Evaluate a sustainable D-Bus approach and its response handling; done means Linux screenshots work across X11 and Wayland, including sandboxed and unsandboxed environments, with the saved location available to the program.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Making a Screenshot on Linux is little bit hacky. Especially on Wayland. @radarhere tried to solve the problem in #6312 by using gnome-screenshot, but this is not a good way. It works only on Systems with Gnome. Of course, you can also add other Screenshot tools but it is far more hacky and it will not work in Sandboxed Environments. Luckily there is a Better Way: There is a official D-Bus API for taking Screenshots. It works in every Desktop Environment in X11 and Wayland. It works also in Sandboxed and Unsandboxed Environments. Here is a Example code that uses it:
import dbus
import dbus.mainloop.glib
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib
def testresp(response, results, object_path):
print(results["uri"])
def main():
loop = GLib.MainLoop()
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
obj = bus.get_object("org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop")
inter = dbus.Interface(obj, "org.freedesktop.portal.Screenshot")
bus.add_signal_receiver(
testresp,
signal_name="Response",
dbus_interface="org.freedesktop.portal.Request",
bus_name="org.freedesktop.portal.Desktop",
path_keyword="object_path")
inter.Screenshot("", {})
loop.run()
main()
It needs the dbus-python. This Lib might not be the best choice, since it might be tricky to install and the mainloop can cause problems.
You can also use this API with the Shell:
gdbus call --session --dest org.freedesktop.portal.Desktop --object-path /org/freedesktop/portal/desktop --method org.freedesktop.portal.Screenshot.Screenshot "" {}
This makes a Screenshot, but I haven't found a Way to get the response, so the Program don't know where the Screenshot has been saved.
This Issue is a note that this API exists. If someone reading this with a better knowledge of D-Bus, he or she can write a better code in a more sustainable lib and make a PR. I might also take a closer look at this when I have some free time.
- Langage dominant
- Python
- Étoiles
- 14k
- Forks
- 2.6k
- Merge moyen
- 1 j 1 h
- PR mergées (30 j)
- 205
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de python-pillow/Pillow
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
python-pillow/Pillow#10590 ·
Les mainteneurs répondent en général sous 1 jour
-
Image.thumbnail() raises ZeroDivisionError when the target height is 0Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
python-pillow/Pillow#10589 ·
Les mainteneurs répondent en général sous 1 jour
-
Sun raster files with RLE encoding and odd-width rows decode shiftedPeut-être pris @PerryLink l’a pris il y a 21 jours. Ouverte🤖-assisted
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
python-pillow/Pillow#10370 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Warn that pre-applying arabic_reshaper + python-bidi corrupts text on a Raqm buildPeut-être pris @Syamjith-NK l’a pris il y a 85 jours. OuverteDocumentation Font Rendering PNG Third Party Framework
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
python-pillow/Pillow#9907 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Example code in ImageText documentation makes incorrect use of get_bbox()Peut-être pris @mmporong l’a pris il y a 1 jour. OuverteDocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 25/100
python-pillow/Pillow#10583 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de python-pillow/Pillow
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
vllm-project/vllm#69304 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
interpreter-core type-bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
pydanty:is-working
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
pydantic/pydantic-ai#14187 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
test
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
prebid/salesagent#2676 ·
Les mainteneurs répondent en général sous 1 jour