Screenshot from the command line on Wayland

The default screenshot tool is cool and all, but I need to be able to run it from the command line, as I won’t have a keyboard attached so it has to run from the command menu extension.

Solution on x11: scrot -f -s -p -F "Pictures/Screenshots/screenshot%Y-%m-%d_%H-%M-%S.png" --exec 'xclip -selection clipboard -t image/png -i $f'

Solution on Wayland: grim -g "$(slurp)" EXCEPT: slurp doesn’t work because compositor doesn't support zwlr_layer_shell_v1. As far as I can find it is not possible to start the Gnome screenshot tool via dbus on the command line. Please prove me wrong.

Updates:

  • Have attempted to modify the DBus permissions for the screenshot interface, without any success. My computer might as well not even have a root user for all the progress I’ve been able to make there.
  • Trying to use ydotool to press the printscreen key. Have discovered that Linux apparently recognizes the printscreen key and the system request key as the same thing for some reason. Would like to see if running the system request key triggers the screenshot tool, but ydotool will NOT stop segfaulting so I haven’t gotten that far.

I’ve only been on it for about a week but I can honestly say I DESPISE Wayland right now. It has made every single scripting job in the last week ten to twenty times harder. Flatpak has its Flatseal where I can waive my extra security protections in exchange for functionality - Wayland has nothing. It’s like being on an iphone.

Gave up and installed gnome-screenshot (the old one). Capturing a selection does not work with a touchscreen. Once again my device is a second-class citizen. Not sure if this is a result of Gnome screenshot’s development or Gnome’s development as a whole or Wayland in general.

This is going to turn me into the joker. Ksnip on Flatpak (designed for x11) plays nice with the touchscreen, but does not succeed at capturing images; Ksnip as a native package (designed for Wayland) outsources its whole being to the Wayland screenshot portal, which technically functions but not with touch input.

I had to build ydotool from source because my distro packaged version was ungodly out of date. Thankfully by this point I had already done all of the actual setup that needed to be done for the tool to function. The final command is ydotool key 99:1 99:0 to press and release the SysRq aka PrintScreen key and call the Gnome screenshot tool

1 Like

You mean you can’t control the area to capture using the touch screen? This sounds like a bug, and I suggest to open an issue on gnome-shell about it.

Can you expand on what you mean? The built in screenshot tool doesn’t work at all with the touchscreen, or do you mean the preview dialog?