Created
March 10, 2021 11:58
-
-
Save sochotnicky/b28ed56a176a347026d2f5f430032180 to your computer and use it in GitHub Desktop.
/home/w0rm/bin/screenshot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z "$1" ]; then | |
| echo "Need screenshot type (screen, window, selection) as argument" | |
| exit 1 | |
| fi | |
| case "$1" in | |
| whole) | |
| export IMG=~/Pictures/Screenshots/whole-$(date | sed 's/ /_/g;s/:/./g').png | |
| grim $IMG | |
| ;; | |
| window) | |
| export IMG=~/Pictures/Screenshots/window-$(date | sed 's/ /_/g;s/:/./g').png | |
| grim -g "$(swaymsg -t get_tree | \ | |
| jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | \ | |
| slurp)" $IMG | |
| ;; | |
| screen) | |
| out=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused).name') | |
| export IMG=~/Pictures/Screenshots/$out-$(date | sed 's/ /_/g;s/:/./g').png | |
| grim -o $out $IMG | |
| ;; | |
| selection) | |
| export IMG=~/Pictures/Screenshots/selection-$(date | sed 's/ /_/g;s/:/./g').png | |
| grim -g "$(slurp)" $IMG | |
| esac | |
| wl-copy < $IMG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment