libcapture.sh 463 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. function capture_linux() {
  3. local title="$1"
  4. local output="$2"
  5. import -window "$title" "$output"
  6. }
  7. function capture_osx() {
  8. local title="$1"
  9. local output="$2"
  10. # get system id of the new created window
  11. sys_id=$(./windowid.swift "kitty" "$title")
  12. screencapture -wl"$sys_id" "$output"
  13. }
  14. function capture() {
  15. if [[ "$OSTYPE" == "linux-gnu" ]]; then
  16. capture_linux "$@"
  17. elif [[ "$OSTYPE" == "darwin"* ]]; then
  18. capture_osx "$@"
  19. fi
  20. }