screenshot-selection 455 B

12345678
  1. #!/bin/bash
  2. [ -d $(xdg-user-dir PICTURES)/screenshots ] || mkdir -p $(xdg-user-dir PICTURES)/screenshots
  3. dimensions=$(slurp 2>/dev/null)
  4. if [ $? -eq 0 ]; then
  5. grim -g "$dimensions" "$(xdg-user-dir PICTURES)/screenshots/$(date +'%Y%m%d_%H%M%S%N.png')"
  6. else
  7. 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')"
  8. fi