Capturing screenshots on WebOS


#1

I'm looking for a way to take screenshots either with some utility or programmatically using API. The application I'm using has that functionality (written in Java, AWT library) but it doesn't work since WebOS seem to be using Wayland, and not X11. The following error is logged:

java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.

I also considered using Xwayland in order to have X11 compatible interface, though couldn't find any related information and if capturing screenshots is possible with it.


#2

It seems there's no API available for this in webOS OSE (yet). It used to be in LunaSysMgr from Open webOS as per https://github.com/openwebos/luna-sysmgr/blob/1393f0af5dd8d9f0e9cc79627f4acb226f8c8d45/Src/base/WindowServer.cpp#L646

On legacy webOS 3.0.x you could take screenshots with Home & Power button.

In LuneOS (based on Open webOS) we implemented it in our own UI.


#3

Thanks for your response.
And what wayland compositor is used now in webOS OSE? And are there any plans to implement screenshot functionality in it?
As I understand there's no use in installing xwayland as wayland doesn't have screenshot API anyway?


#4

I don't know whether it is helpful to you or not. but luna-surfacemanager in webOS OSE has a screenshot source.


#5

I was able to capture screenshot with this command:

luna-send -n 1 -f luna://com.webos.surfacemanager/captureCompositorOutput '{"output":"/home/root/screenshot-temp.jpg","format":"JPG"}'

Though a problem that at the time when screenshot was taken a video was playing on the screen, screenshot is always a black picture. On other content it works.