From e0a6fa47ca040db3396897ba04e4f7a5f35f6b40 Mon Sep 17 00:00:00 2001 From: natemaia Date: Wed, 22 Dec 2021 12:13:19 -0800 Subject: [PATCH] Initial work on sway skel --- sway-home/.local/bin/screenshot | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 sway-home/.local/bin/screenshot diff --git a/sway-home/.local/bin/screenshot b/sway-home/.local/bin/screenshot new file mode 100755 index 00000000..b53e5333 --- /dev/null +++ b/sway-home/.local/bin/screenshot @@ -0,0 +1,27 @@ +#!/bin/bash + +# Shortened version of https://github.com/moverest/sway-interactive-screenshot +# w/o rofi, for use with key bindings + +list_geometry() +{ + swaymsg -t get_tree | jq -r '.. | (.nodes? // empty)[] | select(.'"$1"' and .pid) | "\(.rect.x),\(.rect.y) \(.rect.width)x\(.rect.height)''"' +} + +FOCUSED=$(list_geometry focused) +CHOICE=$1 +DIR=${SCREENSHOT_DIR:=$HOME/Screenshots} +FILENAME="${DIR/#\~/$HOME}/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')" + +mkdir -p "$DIR" + +case $CHOICE in + fullscreen) grim "$FILENAME" ;; + region) grim -g "$(slurp)" "$FILENAME" ;; + focused) grim -g "$FOCUSED" "$FILENAME" ;; + display) grim -o "$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')" "$FILENAME" + ;; +esac + +wl-copy < "$FILENAME" +notify-send "Screenshot" "File saved as '$FILENAME' and copied to the clipboard." -i "$FILENAME"