How To Take Screenshots From Command Line Using “Scrot” In Linux

Take Screenshots From Command Line Using Scrot
Take Screenshots From Command Line Using Scrot In Linux

6 Responses

  1. SonicEricsson says:

    I usually use a region to screenshot.

  2. gazoo says:

    What a great tutorial! Very easy to follow with great examples. I didn’t even know this was installed by default and it worked like described above. This is going to be my goto screenshot program. Whenever I can find an (easy to use, full-featured) terminal version of a GUI program, I prefer to use it instead.

    Ever so slowly… this transitioning Linux user is coming across some great command-line programs.

  3. Josef says:

    Hi

    I’m trying to create a script with scrot where I can setup things like: image format, quality, destination folder, etc.. This is what I have done so far:

    ————> Script begins here

    export IMAGE_FORMAT=jpg
    IMAGE_QUALITY=50
    export DISPLAY=:0
    SCREENSHOT_DIR=”/media/my_path”
    DAY=`date +’%d’`
    MONTH=`date +’%m’`
    YEAR=`date +’%Y’`
    export SAVE_TO_DIR=”$SCREENSHOT_DIR/$YEAR.$MONTH.$DAY”
    mkdir -p “$SAVE_TO_DIR”

    scrot ‘%H.%M.%S_$wx$h.$IMAGE_FORMAT’ -e ‘mv $f \$SAVE_TO_DIR’ -q $IMAGE_QUALITY -z

    <———— Script ends here

    But I will get the error:
    giblib error: Saving to file 13.42.00_1920x1080.IMAGE_FORMAT failed

    If I tried to escape the '$' sign:
    scrot '%H.%M.%S_$wx$h.\$IMAGE_FORMAT' -e 'mv $f \$SAVE_TO_DIR' -q $IMAGE_QUALITY -z

    then I will get:
    giblib error: Saving to file 13.42.00_1920x1080.$IMAGE_FORMAT failed

    Only hard-coding the file extension works:
    scrot '%H.%M.%S_$wx$h.jpg' -e 'mv $f \$SAVE_TO_DIR' -q $IMAGE_QUALITY -z

    But I want to have it on a variable. Do you have any ideas of achieving this?

    Thanks
    Josef

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.