1
0
Fork 0
dotfiles/files/bin/sshot

42 lines
960 B
Plaintext
Raw Normal View History

2018-03-10 04:04:29 +00:00
#!/bin/bash
## sshot - Take a screenshot
if [[ "$1" == "--partial" ]]; then
ARG_PARTIAL=1
elif [[ "$1" == "--pin" ]]; then
ARG_PARTIAL=1
ARG_PIN=1
elif [[ "$1" == "--window" ]]; then
ARG_WINDOW=1
fi
file="$HOME/Pictures/screenshots/$(date --iso-8601=seconds).png"
mkdir -p "$(dirname $file)" 2>/dev/null
if [[ -n "$ARG_PARTIAL" ]]; then
# prompt the user for the area to take a screenshot from
2019-04-03 02:14:14 +00:00
geometry="$(slurp)"
2018-03-10 04:04:29 +00:00
if [ -z "$geometry" ]; then
exit 1
fi
elif [[ -n $ARG_WINDOW ]]; then
# get the active window geometry
2019-04-03 02:14:14 +00:00
geometry="$(get-focused-window-geometry)"
2018-03-10 04:04:29 +00:00
fi
# take a screenshot
2019-04-03 02:14:14 +00:00
grim -g "$geometry" -- "$file"
2018-03-10 04:04:29 +00:00
# place to image in the clipboard
2019-04-03 02:14:14 +00:00
wl-copy < "$file"
2018-03-10 04:04:29 +00:00
if [[ -n "$ARG_PIN" ]]; then
# pin the screenshot
2019-04-04 21:44:39 +00:00
feh --title "Pinned screenshot" --geometry "$(echo -n "$geometry" | sed -E 's/([0-9]+),([0-9]+) ([0-9]+)x([0-9]+)/\3x\4+\1+\2/')" "$file" &
2018-03-10 04:04:29 +00:00
fi
# print the file name
echo "$file"