screenshot-selection 362 B

1234567
  1. #!/bin/bash
  2. dimensions=$(slurp 2>/dev/null)
  3. if [ $? -eq 0 ]; then
  4. grim -g "$dimensions" "$(xdg-user-dir PICTURES)/screenshots/$(date +'%Y%m%d_%H%M%S%N.png')"
  5. else
  6. grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" "$(xdg-user-dir PICTURES)/screenshots/$(date +'%Y%m%d_%H%M%S%N.png')"
  7. fi