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

47 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
export XCURSOR_SIZE=40
export XCURSOR_THEME='Breeze_Snow'
if which xdg-user-dir >/dev/null 2>&1; then
DESTFOLDER="$(xdg-user-dir PICTURES)"
else
for i in Images Imagens Pictures Fotos ""; do
DESTFOLDER="$HOME/$i"
test -d "$DESTFOLDER" &&
break
done
fi
DESTFOLDER="$DESTFOLDER/Screenshots"
mkdir -p "$DESTFOLDER"
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 -b 30303088)" "$DESTFILE"
echo "$DESTFILE"
;;
area-clip)
# Screen area to clipboard
grim -g "$(slurp -d -b 30303088)" - | 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