Skip to content

Instantly share code, notes, and snippets.

@Snarp
Created April 25, 2025 20:10
Show Gist options
  • Save Snarp/690f4c89f07da1bef54b1f5cc521c5a8 to your computer and use it in GitHub Desktop.
Save Snarp/690f4c89f07da1bef54b1f5cc521c5a8 to your computer and use it in GitHub Desktop.
Linux Bash screenshot examples: gnome-screenshot & scrot
#!/bin/bash
STRFTIME="%Y-%m-%d %H-%M-%S %3N" # 2025-01-01 13:01:01 001
DIR="$HOME/Pictures/Screenshots"
EXTNAME="jpg"
FILENAME="$DIR/$(date +"$STRFTIME").$EXTNAME"
# echo "$FILENAME"
mkdir -p "$DIR"
# # gnome-screenshot is Mint default; has fewer options than scrot (below):
# # - <https://gitlab.gnome.org/GNOME/gnome-screenshot>
gnome-screenshot -f "$FILENAME" # fullscreen
gnome-screenshot -w -f "$FILENAME" # focused window
# # scrot needs to be installed: `sudo apt install scrot`
# # - <https://manpages.debian.org/testing/scrot/scrot.1.en.html>
# # - <https://github.com/resurrecting-open-source-projects/scrot>
scrot "$FILENAME" # fullscreen
scrot -u -b "$FILENAME" # focused window (with border)
scrot -q 75 "$FILENAME" # set JPG compression level
# One-liners:
gnome-screenshot -f "$HOME/Pictures/Screenshots/$(date +"%Y-%m-%d %H-%M-%S %3N").jpg"
scrot "$HOME/Pictures/Screenshots/$(date +"%Y-%m-%d %H-%M-%S %3N").jpg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment