Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Software] CLI screenshot tool

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
galluzHalevi
Posts: 5
Joined: 2022-10-22 08:16

[Software] CLI screenshot tool

#1 Post by galluzHalevi »

Hello,
I have just installed Debian 12, w/ Gnome 43.
I really need a cli tool to make screenshots. Specifically a rectangular area.
Moving from Mint, I used shutter, but I cant seem to find anything that works native and smooth on Wayland.
I tried
1. shutter, scrot - no wayland support
2. shutter-on-wayland - officially supports ubuntu 23.10, buggy (gtk-critical error that keeps showing way after command finished)
3. import - this error:
import-im6.q16: unable to read X window image `': Resource temporarily unavailable @ error/xwindow.c/XImportImage/4977.
import-im6.q16: missing an image filename `/home/gal/Pictures/Screenshots/tmp.png' @ error/import.c/ImportImageCommand/1276.
4. grim - this error:
compositor doesn't support wlr-screencopy-unstable-v1

Any suggestions?
Thanks, Gal

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: [Software] CLI screenshot tool

#2 Post by Dai_trying »

I use a default gnome installation and just press printscreen button (prtscn) which pops up a square which you can drag to the area to capture, files are saved (by default) in /home/<user>/Pictures/Screenshots/

HTH

User avatar
bbbhltz
Posts: 166
Joined: 2024-01-10 14:53
Location: Normandy
XMMP/Jabber: bbbhltz@mailbox.org
Has thanked: 49 times
Been thanked: 33 times

Re: [Software] CLI screenshot tool

#3 Post by bbbhltz »

Here are a few screenshot tools that should work under wayland. Some of them have CLI commands for taking screenshots:

https://flameshot.org/ / is in repo
https://github.com/emersion/slurp / is in repo
https://gitlab.com/WhyNotHugo/shotman / not in repo
https://github.com/jtheoof/swappy / not in repo
bbbhltz
longtime desktop Linux user; eternal newbie

galluzHalevi
Posts: 5
Joined: 2022-10-22 08:16

Re: [Software] CLI screenshot tool

#4 Post by galluzHalevi »

I sometimes need to make a screenshot of a specific area once a second for 10 minutes. I used to do it using a bash file, alternating from "sleep 1" to "shutter -s ..."
I really need a CLI tool...

galluzHalevi
Posts: 5
Joined: 2022-10-22 08:16

Re: [Software] CLI screenshot tool

#5 Post by galluzHalevi »

Solved
So what I didn't know is that in the login screen I can choose a "Gnome on Xorg" session. This means I can use every tool I'm used too, and when I'm finished just log out and login again to have all the cool wayland features like touchpad gestures. That is a compromise I'm comfortable with.
Although, It does seem weird that there is no easy tool native to wayland at that point. I did try some more suggestions:
5. flameshot - takes black screenshots
6. slurp - couldn't take full advantage without grim, didn't suit all my needs
7. shotman - depricated, didn't want to go that way
8. swappy - depended on grim

Thanks, Gal

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: [Software] CLI screenshot tool

#6 Post by Dai_trying »

I have a script that I call for screenshots using xwd (with Xfce) but I don't know if that will work with wayland, I will try it out when I get the chance (in the middle of backups at moment) and post back.

pwzhangzz
Posts: 441
Joined: 2020-11-11 17:42
Has thanked: 10 times
Been thanked: 27 times

Re: [Software] CLI screenshot tool

#7 Post by pwzhangzz »

galluzHalevi wrote: 2024-03-01 13:10 Solved
So what I didn't know is that in the login screen I can choose a "Gnome on Xorg" session.
Don't do that! Just use the plain vanilla gnome cli screenshot tool: gnome-screenshot (you need to install it). Works with wayland.

pwzhangzz
Posts: 441
Joined: 2020-11-11 17:42
Has thanked: 10 times
Been thanked: 27 times

Re: [Software] CLI screenshot tool

#8 Post by pwzhangzz »

The following simple command will take screenshots from to-be-selected areas every second for 5 seconds:

Code: Select all

for i in {1..5}; do gnome-screenshot -a  -d  1  -f  test$i; done
Unfortunately, due to my low bash skill, I don't know how to continuously take screenshots of a pre-defined area for a set time interval. Thus, no help.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: [Software] CLI screenshot tool

#9 Post by Dai_trying »

@galluzHalevi
I revisited my original screen capture scripts and found they would not work with wayland (no surprise really) and did a little research and found that getting a user defined area of screen captured is not a viable option for wayland (at least not under Gnome) so I went back to my script to see about capturing a user defined area and modified my script to accept parameters so that it could be called by your own script to capture at a rate you would prefer.

This would need to be run under "Gnome on Xorg", which is what your solution states you are now doing anyway, but you could use this to capture the screen as you wanted by incorporating @pwzhangzz offered snippet

Here is the script which I have named as scrsh3

Code: Select all

#!/bin/bash

if [ $# -lt 4 ]
    then
        echo "Not enough arguments supplied"
        echo "This script needs the following parameters"
        echo "width height xposition yposition"
        exit 1
fi

w=$1
h=$2
x=$3
y=$4

Pic_Path="/home/$USER/Pictures/"
Pic_Name="ScreenShot"
nowtime=$(date +"%Y-%m-%d_%H:%M:%S")


xwd -root | convert -crop "$w"x"$h"+"$x"+"$y" xwd:- ${Pic_Path}${nowtime}_${Pic_Name}.png
HTH

Aki
Global Moderator
Global Moderator
Posts: 2979
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 75 times
Been thanked: 407 times

Re: [Software] CLI screenshot tool

#10 Post by Aki »

Moderator edit: replacing "screemshot" with "screenshot" in the subject of posts
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

pwzhangzz
Posts: 441
Joined: 2020-11-11 17:42
Has thanked: 10 times
Been thanked: 27 times

Re: [Software] CLI screenshot tool

#11 Post by pwzhangzz »

The following command was supposed to take screenshots on a predefined rectangular area every second for three seconds:

Code: Select all

for i in {1..3}; do gnome-screenshot  -a  -d  1  -f gtest$i; ydotool mousemove 100 100 mousedown 1 mousemove 300 300 mouseup 1; done
However, I had to manually click the mouse before each screenshot was taken (but no need to redraw the rectangle). As a result, the timing is off and this cli is thus useless.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: [Software] CLI screenshot tool

#12 Post by Dai_trying »

I tried this with xdotool when researching but it didn't work either.

Dai_trying
Posts: 1101
Joined: 2016-01-07 12:25
Has thanked: 7 times
Been thanked: 16 times

Re: [Software] CLI screenshot tool

#13 Post by Dai_trying »

This works for me creating images of 100x100 with starting (top left corner) point of x=300 y=300 with a 2 second delay between shots. Adjust the sleep value for preferred timing.

Code: Select all

for i in {1..5}; do scrsh3 100 100 300 300;sleep 2; done
Obviously you would need to place the scrsh3 script in your $PATH and have imagemagick installed. And this needs to run in "Gnome on Xorg" session.

Stiil no joy finding a working Wayland solution... :(

grahamL
Posts: 1
Joined: 2024-03-10 16:44

Re: [Software] CLI screenshot tool

#14 Post by grahamL »

I too have migrated from Ubuntu to Debian 12 and have been a long time user of Shutter but have found that under Wayland, the tool just doesn't open 🙄
I've explored a few alternatives for my use case (require inserting pointers such as arrows) but all I have found available to do this is Libre Office Draw.
Looking at your need for scripting, would LO Scripting Libre Office Scripting

Post Reply