You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
992 B
37 lines
992 B
#!/bin/bash |
|
#---------------------------------------------------------------- |
|
# screenshot — Capture screen, window, or region |
|
# |
|
# Captures once, saves to ~/Pictures and copies to clipboard. |
|
# |
|
# Usage: |
|
# screenshot full — full screen |
|
# screenshot area — select region with slurp |
|
# screenshot window — focused window |
|
# |
|
# Dependencies: grim, slurp, wl-copy, swaymsg, jq |
|
#---------------------------------------------------------------- |
|
|
|
dir=~/Pictures |
|
mkdir -p "$dir" |
|
file="$dir/screenshot_$(date +%Y%m%d_%H%M%S).png" |
|
|
|
case "$1" in |
|
full) |
|
grim -t png "$file" |
|
;; |
|
area) |
|
geo=$(slurp) |
|
grim -t png -g "$geo" "$file" |
|
;; |
|
window) |
|
geo=$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused) | .rect | "\(.x),\(.y) \(.width)x\(.height)"') |
|
grim -t png -g "$geo" "$file" |
|
;; |
|
*) |
|
echo "Usage: screenshot {full|area|window}" |
|
exit 1 |
|
;; |
|
esac |
|
|
|
wl-copy -t image/png < "$file"
|
|
|