1

Now I need to develop a plug-in that can take screenshots on Ubuntu, CentOS and fedora. I try to write it in Xlib. It can run on Ubuntu and CentOS, but Fedora uses Wayland, and the plug-in that I developed can't work.

Gnome screenshot can work on these platforms, but after reading his source code, I found that it can achieve screenshots by calling other processes, which is hard for me to learn from.

So is there any way I can take a screenshot on Wayland engine?

Yatogami
  • 69
  • 7
  • Fedora : You can always use ImageMagick : `import screen$RANDOM.jpg` → **screenshot-ImageMagick-0.4-1.el6.noarch.rpm** https://drive.google.com/file/d/1Snm-XD37EdMAwT6IOU6OekvRSmC2jCF7/view?usp=sharing – Knud Larsen Jul 12 '21 at 02:35
  • @KnudLarsen It seems doesn't work well on my Wayland system...```import-im6.q16: unable to read X window image `root': Resource temporarily unavailable @ error/xwindow.c/XImportImage/4977.``` – Yatogami Jul 15 '21 at 08:17

1 Answers1

0

I get it in using dbus, here is the light code:

    method_name = "Screenshot";
    method_params = g_variant_new ("(bbs)",
                                     TRUE,
                                     FALSE, /* flash */
                                     filename);

    connection = g_application_get_dbus_connection (g_application_get_default ());
    g_dbus_connection_call_sync (connection,
                               "org.gnome.Shell.Screenshot",
                               "/org/gnome/Shell/Screenshot",
                               "org.gnome.Shell.Screenshot",
                               method_name,
                               method_params,
                               NULL,
                               G_DBUS_CALL_FLAGS_NONE,
                               -1,
                               NULL,
                               &error);
Yatogami
  • 69
  • 7