Taking screenshots with a command-line tool
Maxim Kartashev
maxim.kartashev at jetbrains.com
Mon Mar 20 05:13:54 UTC 2023
Thank you, Niels!
It also turns out that gnome-screenshot(1) works fine in the Wayland
environment despite controversial help text that asks for an optional X
display.
On Fri, Mar 17, 2023 at 4:01 PM Niels De Graef <ndegraef at redhat.com> wrote:
> Hi Maxim,
>
> Taken from
> https://stackoverflow.com/questions/72216896/how-can-i-get-a-screenshot-on-wayland-with-pure-python
>
> ```
> import dbus
> from gi.repository import GLib
> import dbus.mainloop.glib
>
>
> def response_handler(response, result):
> if response == 0:
> print(f'Screenshot file: {result.get("uri")}')
> else:
> print("Failed to get screenshot")
>
>
> def main():
> dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
> bus = dbus.SessionBus()
> my_name = bus.get_connection().get_unique_name()[1:].replace(".", "_")
> response_path =
> f"/org/freedesktop/portal/desktop/request/{my_name}/my_token"
> bus.add_signal_receiver(
> response_handler,
> dbus_interface="org.freedesktop.portal.Request",
> path=response_path,
> )
>
> desktop = bus.get_object("org.freedesktop.portal.Desktop",
> "/org/freedesktop/portal/desktop")
> desktop.Screenshot("Screenshot", {"handle_token": "my_token"},
> dbus_interface="org.freedesktop.portal.Screenshot")
> loop = GLib.MainLoop()
> loop.run()
>
>
> if __name__ == "__main__":
> main()
> ```
>
> -- Niels
>
> On Fri, Mar 17, 2023 at 12:36 PM Maxim Kartashev
> <maxim.kartashev at jetbrains.com> wrote:
> >
> > Does anyone know if there's a command-line for taking
> screenshots/screencasts that works under Gnome 42+? A thing like that would
> be immensely useful for analyzing automated test failures.
> >
> > Thanks in advance,
> > Maxim.
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/wakefield-dev/attachments/20230320/4062605b/attachment-0001.htm>
More information about the wakefield-dev
mailing list