Skip to content

Instantly share code, notes, and snippets.

@nikitabugrovsky
Created June 18, 2020 21:29
Show Gist options
  • Save nikitabugrovsky/029432d38926a9403cfc003a1eb16573 to your computer and use it in GitHub Desktop.
Save nikitabugrovsky/029432d38926a9403cfc003a1eb16573 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# dependencies:
# - imagemagick
# - xdotool
function screenshot() {
local timestamp=$(date "+%Y-%m-%d_%H-%M-%S")
local path="$HOME/Pictures/screenshot_${timestamp}.png"
for i in $(seq 5); do echo "$(printf '%0.s·' $(seq $i))" && sleep 1; done &&
import -window "$(xdotool getwindowfocus -f)" "${path}"
echo "Screenshot path: ${path}"
}
# output
# ·
# ··
# ···
# ····
# ·····
# Screenshot path: <$HOME>/Pictures/screenshot_<$timestamp>.png
# NB you can get focused on any window while program runs to make screenshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment