Help with screenshot API.
rahul vadhyar
vadhyarrahul at gmail.com
Fri Oct 4 15:28:34 BST 2024
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 × 12th Gen Intel® Core™ 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 <vlad.zahorodnii at kde.org>
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/org.kde.KWin.ScreenShot2.xml?ref_type=heads#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=Unique
> >> X-DBUS-ServiceName=org.kde.koolintelligence
> >> X-KDE-DBUS-Restricted-Interfaces=org.kde.KWin.ScreenShot2
> >>
> X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,zkde_screencast_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 =
> >> QString().fromStdString("org.kde.KWin.ScreenShot2");
> >> static const QString screenShotObjectPath =
> >> QString().fromStdString("/org/kde/KWin/ScreenShot2");
> >> static const QString screenShotInterface =
> >> 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 =
> >> 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());
> >> }
> >> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kwin/attachments/20241004/083f417f/attachment.htm>
More information about the kwin
mailing list