this post was submitted on 14 Apr 2025
9 points (100.0% liked)
.NET
1652 readers
1 users here now
Getting started
Useful resources
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
Related communities
Wikipedia pages
- .NET (open source & cross platform)
- .NET Framework (proprietary & Windows-only)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Taking a screenshot in Wayland is tricky, even more so in C#. I'm not aware of a up to date library that takes care of these things for you on Linux in C#.
Your best bet for a clean solution is most likely using the
org.freedesktop.portal.Desktop
portal via d-bus.There's a d-bus library for C#: https://github.com/tmds/Tmds.DBus
Essentially you want to call
org.freedesktop.portal.Screenshot.Screenshot
onorg.freedesktop.portal.Desktop
and then get the file path for the screenshot from the object path that gets returned.Here's a quick example to take a screenshot from the terminal:
https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.impl.portal.Screenshot.html#org-freedesktop-impl-portal-screenshot-screenshot
Other solutions that work via Wayland are:
org.kde.KWin.ScreenShot2
)You need to test with different desktop environments though, the amount of user interaction required to take a screenshot on Wayland varies.
Thank you so much for the detailed reply!