Re: Help with screenshot API.
rahul vadhyar <[email protected]> Fri, 4 Oct 2024 19:58:34 +0530
| Newsgroups | gmane.comp.kde.devel.kwin |
|---|---|
| Message-ID | <CAOL1oibGSZ_sgdtyyWQkjanfjeNuEn2sTJyW90h+j+6g2-Tp4g@mail.gmail.com> |
--0000000000002087290623a77d92 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes, I am running plasma 6.1 on fedora 40. The details of my system are as follows Operating System: Fedora Linux 40 KDE Plasma Version: 6.1.5 KDE Frameworks Version: 6.6.0 Qt Version: 6.7.2 Kernel Version: 6.10.11-200.fc40.x86_64 (64-bit) Graphics Platform: Wayland Processors: 16 =C3=97 12th Gen Intel=C2=AE Core=E2=84=A2 i9-12900K Memory: 46.8 GB of RAM Graphics Processor: NVIDIA GeForce RTX 3080/PCIe/SSE2 Manufacturer: Gigabyte Technology Co., Ltd. Product Name: Z690 UD AX DDR4 Even if CaptureWorkspace returns a dictionary, I shouldn't be getting the error that the API doesn't exist. To provide more context, I am making a kirigami app. I am using the .desktop file as given in the previous email. I am also using the following command for compiling and testing cmake -S . -B build -GNinja && cmake --build build --parallel && sudo cmake --install build/ --prefix "/usr" && koolintelligence I cannot tell where I am going wrong with this. Is there anything else that I can try that might help? Thanks for your help, Rahul On Fri, 4 Oct 2024 at 19:13, Vlad Zahorodnii <[email protected]> wrote: > Also note that CaptureWorkspace returns a dictionary. The API can be > found here > > https://invent.kde.org/plasma/kwin/-/blob/master/src/plugins/screenshot/o= rg.kde.KWin.ScreenShot2.xml?ref_type=3Dheads#L350 > > On 10/4/24 4:40 PM, Vlad Zahorodnii wrote: > > Hi, > > > > CaptureWorkspace was introduced in Plasma 6.0. Are you running Plasma 6= ? > > > > Vlad > > > > On 10/3/24 6:51 PM, rahul vadhyar wrote: > >> Hi, > >> I am Rahul, a college student from India. > >> I am working on a project where I need to take screenshots of the > >> screen for further processing. From looking online and looking at the > >> spectacle code, I have figured out that you need to install the > >> application in /usr/bin and that the .desktop file must contain the > >> following > >> > >> X-DBUS-StartupType=3DUnique > >> X-DBUS-ServiceName=3Dorg.kde.koolintelligence > >> X-KDE-DBUS-Restricted-Interfaces=3Dorg.kde.KWin.ScreenShot2 > >> > X-KDE-Wayland-Interfaces=3Dorg_kde_plasma_window_management,zkde_screenca= st_unstable_v1 > > >> > >> > >> However, even after doing this, I am getting the following error > >> > >> Screenshot failed: No such method 'CaptureWorkspace' in interface 'org= . > >> kde.KWin.ScreenShot2' at object path '/org/kde/KWin/ScreenShot2' > >> (signature '') > >> > >> My code is attached below for reference. Please let me know how I can > >> resolve this issue. > >> > >> #include <QtDBus/QtDBus> > >> #include <QDBusUnixFileDescriptor> > >> #include "logging.hpp" > >> #include <fcntl.h> > >> static const QString screenShotService =3D > >> QString().fromStdString("org.kde.KWin.ScreenShot2"); > >> static const QString screenShotObjectPath =3D > >> QString().fromStdString("/org/kde/KWin/ScreenShot2"); > >> static const QString screenShotInterface =3D > >> QString().fromStdString("org.kde.KWin.ScreenShot2"); > >> void takeScreenshotKwin(std::string path) { > >> // Connect to KWin's screenshot service > >> QDBusInterface interface( > >> screenShotService, > >> screenShotObjectPath, > >> screenShotInterface, > >> QDBusConnection::sessionBus() // Bus connection > >> ); > >> > >> if (!interface.isValid()) { > >> LOG_ERROR("takeScreenshotKwin", "Failed to connect to KWin > >> Screenshot interface"); > >> return; > >> } > >> > >> QDBusReply<QString> reply =3D > >> interface.call(QString().fromStdString("CaptureWorkspace")); > >> > >> if (reply.isValid()) { > >> LOG_INFO("takeScreenshotKwin", "Screenshot saved at: " + path)= ; > >> } else { > >> LOG_ERROR("takeScreenshotKwin", "Screenshot failed: " + > >> reply.error().message().toStdString()); > >> } > >> } > --0000000000002087290623a77d92 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Yes, I am running plasma 6.1 on fedora 40. The details of = my system are as follows<div>Operating System: Fedora Linux 40<br>KDE Plasm= a Version: 6.1.5<br>KDE Frameworks Version: 6.6.0<br>Qt Version: 6.7.2<br>K= ernel Version: 6.10.11-200.fc40.x86_64 (64-bit)<br>Graphics Platform: Wayla= nd<br>Processors: 16 =C3=97 12th Gen Intel=C2=AE Core=E2=84=A2 i9-12900K<br= >Memory: 46.8 GB of RAM<br>Graphics Processor: NVIDIA GeForce RTX 3080/PCIe= /SSE2<br>Manufacturer: Gigabyte Technology Co., Ltd.<br>Product Name: Z690 = UD AX DDR4<br></div><div><br></div><div>Even if CaptureWorkspace returns a = dictionary, I shouldn't be getting the error that the API doesn't e= xist.=C2=A0</div><div><br></div><div>To provide more context, I am making a= kirigami app. I am using the .desktop file as given in the previous email.= I am also using the following=C2=A0command for compiling and=C2=A0testing= =C2=A0</div><div><br></div><div>cmake -S . -B build -GNinja && cmak= e --build build --parallel && sudo =C2=A0cmake --install build/ --p= refix "/usr" && koolintelligence<br></div><div><br></div>= <div>I cannot tell=C2=A0where I am going wrong=C2=A0with=C2=A0this. Is ther= e anything else that I can try that might=C2=A0help?</div><div><br></div><d= iv>Thanks for your help,</div><div>Rahul</div></div><br><div class=3D"gmail= _quote"><div dir=3D"ltr" class=3D"gmail_attr">On Fri, 4 Oct 2024 at 19:13, = Vlad Zahorodnii <<a href=3D"mailto:[email protected]">vlad.zahorod= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding= -left:1ex">Also note that CaptureWorkspace returns a dictionary. The API ca= n be <br> found here <br> <a href=3D"https://invent.kde.org/plasma/kwin/-/blob/master/src/plugins/scr= eenshot/org.kde.KWin.ScreenShot2.xml?ref_type=3Dheads#L350" rel=3D"noreferr= er" target=3D"_blank">https://invent.kde.org/plasma/kwin/-/blob/master/src/= plugins/screenshot/org.kde.KWin.ScreenShot2.xml?ref_type=3Dheads#L350</a><b= r> <br> On 10/4/24 4:40 PM, Vlad Zahorodnii wrote:<br> > Hi,<br> ><br> > CaptureWorkspace was introduced in Plasma 6.0. Are you running Plasma = 6?<br> ><br> > Vlad<br> ><br> > On 10/3/24 6:51 PM, rahul vadhyar wrote:<br> >> Hi,<br> >> I am Rahul, a college student from India.<br> >> I am working on a project where=C2=A0I need to take screenshots of= the <br> >> screen for further processing. From looking online and looking at = the <br> >> spectacle code, I have figured out that you need to install the <b= r> >> application in /usr/bin and that the .desktop file must contain th= e <br> >> following<br> >><br> >> X-DBUS-StartupType=3DUnique<br> >> X-DBUS-ServiceName=3Dorg.kde.koolintelligence<br> >> X-KDE-DBUS-Restricted-Interfaces=3Dorg.kde.KWin.ScreenShot2<br> >> X-KDE-Wayland-Interfaces=3Dorg_kde_plasma_window_management,zkde_s= creencast_unstable_v1 <br> >><br> >><br> >> However, even after doing this, I am getting the following error<b= r> >><br> >> Screenshot failed: No such method 'CaptureWorkspace' in in= terface 'org.<br> >> kde.KWin.ScreenShot2' at object path '/org/kde/KWin/Screen= Shot2' <br> >> (signature '')<br> >><br> >> My code is attached below for reference. Please let me know how I = can <br> >> resolve this issue.<br> >><br> >> #include <QtDBus/QtDBus><br> >> #include <QDBusUnixFileDescriptor><br> >> #include "logging.hpp"<br> >> #include <fcntl.h><br> >> static const QString screenShotService =3D <br> >> QString().fromStdString("org.kde.KWin.ScreenShot2");<br> >> static const QString screenShotObjectPath =3D <br> >> QString().fromStdString("/org/kde/KWin/ScreenShot2");<br= > >> static const QString screenShotInterface =3D <br> >> QString().fromStdString("org.kde.KWin.ScreenShot2");<br> >> void takeScreenshotKwin(std::string path) {<br> >> =C2=A0 =C2=A0 // Connect to KWin's screenshot service<br> >> =C2=A0 =C2=A0 QDBusInterface interface(<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 screenShotService,<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 screenShotObjectPath,<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 screenShotInterface,<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 QDBusConnection::sessionBus() // Bus c= onnection<br> >> =C2=A0 =C2=A0 );<br> >><br> >> =C2=A0 =C2=A0 if (!interface.isValid()) {<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 LOG_ERROR("takeScreenshotKwin&quo= t;, "Failed to connect to KWin <br> >> Screenshot interface");<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;<br> >> =C2=A0 =C2=A0 }<br> >><br> >> =C2=A0 =C2=A0 QDBusReply<QString> reply =3D <br> >> interface.call(QString().fromStdString("CaptureWorkspace"= ;));<br> >><br> >> =C2=A0 =C2=A0 if (reply.isValid()) {<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 LOG_INFO("takeScreenshotKwin"= ;, "Screenshot saved at: " + path);<br> >> =C2=A0 =C2=A0 } else {<br> >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 LOG_ERROR("takeScreenshotKwin&quo= t;, "Screenshot failed: " + <br> >> reply.error().message().toStdString());<br> >> =C2=A0 =C2=A0 }<br> >> }<br> </blockquote></div> --0000000000002087290623a77d92--