aboutsummaryrefslogtreecommitdiff
path: root/bin/screenshot
diff options
context:
space:
mode:
Diffstat (limited to 'bin/screenshot')
-rwxr-xr-xbin/screenshot22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/screenshot b/bin/screenshot
new file mode 100755
index 0000000..94e3bd3
--- /dev/null
+++ b/bin/screenshot
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o nounset
+set -o pipefail
+if [[ "${TRACE-0}" == "1" ]]; then
+ set -o xtrace
+fi
+
+
+FOCUSED=$(swaymsg -t get_tree | jq '.. | (.nodes? // empty)[] | select(.focused) | .rect | "\(.x),\(.y) \(.width)x\(.height)"')
+
+main() {
+ rect="$(slurp)"
+ if [ $? -eq 0 ]; then
+ grim -g "$rect" -t png - | wl-copy -t image/png
+ else
+ grim -g "$(eval echo "$FOCUSED")" -t png - | wl-copy -t image/png
+ fi
+
+}
+
+main "$@"