The format of the raw file you capture is going to depend on the bit depth and resolution.
There are a number of tools out there to do this. Debian has the fbcat
package. You may need to sudo apt-get install fbcat
to install it.
fbcat
will grab the frame buffer in ppm
format, so you can then use ppmtojpeg
or similar to convert it to the format you want.
There's also a fbgrab
wrapper which will save in PNG format.
For Wayland
Based on information from n-tchen, Flameshot (in the Fedora repos) works well:
flameshot screen -p ~/
If you are connected via ssh, add WAYLAND_DISPLAY=wayland-0
at the beginning of the above line.
You can also use gnome-screenshot
instead of Flameshot, but you'll still need the above addition for ssh.
Additional information (source):
The cross-platform way to take screenshots on Wayland is via xdg-desktop-portal (which also works outside of Flatpak). See https://github.com/flatpak/xdg-desktop-portal/blob/master/data/org.freedesktop.portal.Screenshot.xml
Finally, Pyscreenshot supports Wayland; see the GitHub README
For X11
The import
command from ImageMagick does a great job of screenshots:
import -silent -window root /tmp/screenshot.jpg
If you are connected via ssh, add DISPLAY=:0.0
at the beginning of the above line, and you'll need to be logged in as the same user that is logged in locally.
If you want to run this in crontab, here is how to set it up. This will take a screenshot every 6 minutes and store it with a date-time-encoded filename in /root/monitor/
. It has been tested on Ubuntu 16.04 and 18.04.
echo -n "/bin/bash -c '" >cronexec
echo -n 'export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && ' >>cronexec
echo -n 'export HOME=/root && ' >>cronexec
echo -n 'export D1=/tmp/gneemp && ' >>cronexec
echo -n 'export F2=`date --utc +/root/monitor/%Y-%m-%dT%H:%M.jpg` && ' >>cronexec
echo -n 'mkdir -p $D1 && ' >>cronexec
echo -n 'chmod 643 $D1 && ' >>cronexec
echo -n 'DISPLAY=:0.0 sudo -u `who --users |head -1 |grep -o "^\S*"` import -quiet -silent -window root $D1/tmp.jpg && ' >>cronexec
echo -n 'mkdir -p /root/monitor && ' >>cronexec
echo -n 'mv $D1/tmp.jpg $F2 && ' >>cronexec
echo -n 'rmdir $D1 ' >>cronexec
echo "'" >>cronexec
perl -p -i -e 's|\%|\\\%|g;' cronexec # from the manpage: "Percent-signs (%) in the command, unless escaped with backslash (\) ..."
(sudo crontab -l 2>/dev/null; echo -n "*/6 * * * * "; cat cronexec) |sudo crontab - && rm cronexec
Best Answer
The screenshot recipe you are asking about uses the
gnome-utils
package. However, as you can check, the last Debian release that included that package was squeeze.Since the functionality you describe uses
gnome-utils
, and since that package is no longer in Debian, it is not surprising the method does not work.Additionally you can check the info tab of https://wiki.debian.org/ScreenShots, and you'll see the image from there that you include in your question was added in 2007.
Summary: I recommend you use another method to obtain a screenshot. There are many such methods.