re-add screengrab script

This commit is contained in:
Mark Riedesel 2024-07-31 14:08:59 -05:00
parent b18beb9aca
commit 85080081bc

23
bin/screengrab Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env sh
set -euo pipefail
DIR=${XDG_SCREENSHOT_DIR:-$HOME}
TARGET="${DIR}/screenshot/grab-$(date +'%Y%m%d%H%M%S').png"
has() {
command -v $1 &>/dev/null
}
die() {
echo $1
exit 1;
}
has grim || die "missing grim"
has wl-copy || die "missing wl-copy"
has slurp || die "missing slurp"
grim -g "$(slurp)" $TARGET
if [ -s $TARGET ]; then
wl-copy < $TARGET
fi