This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/dotfiles/scripts/screenshotsh

44 lines
938 B
Bash
Executable File

#!/bin/sh
if which xdg-user-dir &> /dev/null
then
DESTFOLDER=$(xdg-user-dir PICTURES)
else
for i in Images Imagens Pictures Fotos ""
do
DESTFOLDER=$HOME/$i
test -d "$DESTFOLDER" &&
break
done
mkdir -p $DESTFOLDER
fi
DESTFILE=$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')
case $1 in
def)
# Screenshot to file
grim $DESTFILE
echo $DESTFILE
;;
area)
# Screen area to file
grim -g "$(slurp -d)" $DESTFILE
echo $DESTFILE
;;
area-clip)
# Screen area to clipboard
grim -g "$(slurp -d)" - | wl-copy
;;
clip)
# Focused monitor to clipboard
cur_output=$(swaymsg -t get_outputs |
jq -r '.[] | select(.focused) | .name')
test -n "$cur_output" &&
grim -o "$cur_output" - | wl-copy ||
grim - | wl-copy
;;
esac