diff --git a/scripts/screenshot/screenshot_area.sh b/scripts/screenshot/screenshot_area.sh index ff73b92..c12ff8f 100755 --- a/scripts/screenshot/screenshot_area.sh +++ b/scripts/screenshot/screenshot_area.sh @@ -22,11 +22,22 @@ fi # Open the editor if satty is available (blocks until it is closed). # satty writes the annotated image to --output-filename on Ctrl+s (and on -# Esc/Enter here) and exits immediately. +# Esc/Enter here) and exits immediately. It is launched floating, without +# decorations, with the pen preselected and moved over the captured area. if command -v satty >/dev/null 2>&1; then + x=$(cut -d, -f1 <<< "$geometry") + y=$(cut -d, -f2 <<< "$geometry" | cut -d' ' -f1) satty --filename "$dir/$file" --output-filename "$dir/$file" \ --copy-command wl-copy --actions-on-escape save-to-file --early-exit \ - --floating-hack + --floating-hack --no-window-decoration --initial-tool brush & + pid=$! + for _ in $(seq 1 20); do + addr=$(hyprctl clients -j 2>/dev/null | jq -r --argjson p "$pid" '.[] | select(.pid == $p) | .address' | head -1) + [ -n "$addr" ] && break + sleep 0.1 + done + [ -n "$addr" ] && hyprctl dispatch movewindowpixel "exact $x,$y,address:$addr" >/dev/null 2>&1 + wait "$pid" wl-copy -t image/png < "$dir/$file" fi diff --git a/scripts/screenshot/screenshot_monitor.sh b/scripts/screenshot/screenshot_monitor.sh index 7f01b77..ff738bd 100755 --- a/scripts/screenshot/screenshot_monitor.sh +++ b/scripts/screenshot/screenshot_monitor.sh @@ -23,11 +23,22 @@ fi # Open the editor if satty is available (blocks until it is closed). # satty writes the annotated image to --output-filename on Ctrl+s (and on -# Esc/Enter here) and exits immediately. +# Esc/Enter here) and exits immediately. It is launched floating, without +# decorations, with the pen preselected and moved over the captured area. if command -v satty >/dev/null 2>&1; then + x=$(hyprctl monitors -j | jq -r --arg m "$monitor" '.[] | select(.name == $m) | .x') + y=$(hyprctl monitors -j | jq -r --arg m "$monitor" '.[] | select(.name == $m) | .y') satty --filename "$dir/$file" --output-filename "$dir/$file" \ --copy-command wl-copy --actions-on-escape save-to-file --early-exit \ - --floating-hack + --floating-hack --no-window-decoration --initial-tool brush & + pid=$! + for _ in $(seq 1 20); do + addr=$(hyprctl clients -j 2>/dev/null | jq -r --argjson p "$pid" '.[] | select(.pid == $p) | .address' | head -1) + [ -n "$addr" ] && break + sleep 0.1 + done + [ -n "$addr" ] && hyprctl dispatch movewindowpixel "exact $x,$y,address:$addr" >/dev/null 2>&1 + wait "$pid" wl-copy -t image/png < "$dir/$file" fi diff --git a/scripts/screenshot/screenshot_window.sh b/scripts/screenshot/screenshot_window.sh index b804934..368ec70 100755 --- a/scripts/screenshot/screenshot_window.sh +++ b/scripts/screenshot/screenshot_window.sh @@ -42,11 +42,22 @@ fi # Open the editor if satty is available (blocks until it is closed). # satty writes the annotated image to --output-filename on Ctrl+s (and on -# Esc/Enter here) and exits immediately. +# Esc/Enter here) and exits immediately. It is launched floating, without +# decorations, with the pen preselected and moved over the captured area. if command -v satty >/dev/null 2>&1; then + x=$(cut -d, -f1 <<< "$geometry") + y=$(cut -d, -f2 <<< "$geometry" | cut -d' ' -f1) satty --filename "$dir/$file" --output-filename "$dir/$file" \ --copy-command wl-copy --actions-on-escape save-to-file --early-exit \ - --floating-hack + --floating-hack --no-window-decoration --initial-tool brush & + pid=$! + for _ in $(seq 1 20); do + addr=$(hyprctl clients -j 2>/dev/null | jq -r --argjson p "$pid" '.[] | select(.pid == $p) | .address' | head -1) + [ -n "$addr" ] && break + sleep 0.1 + done + [ -n "$addr" ] && hyprctl dispatch movewindowpixel "exact $x,$y,address:$addr" >/dev/null 2>&1 + wait "$pid" wl-copy -t image/png < "$dir/$file" fi