add screenshot script+binds

This commit is contained in:
lucy 2026-08-25 00:04:30 +02:00
commit 60a6364fa0
2 changed files with 30 additions and 2 deletions

View file

@ -146,8 +146,9 @@ bind=SUPER,Return,spawn,foot
bind=SUPER+SHIFT,q,quit
bind=SUPER,q,killclient,
# screenshot binds
bind = SUPER+SHIFT,S,spawn_shell,grim -g "$(slurp)" - | wl-copy
bind=ALT+SHIFT,S,spawn_shell,grim -o "$(mmsg get all-monitors | jq -r '.monitors[] | select(.active) | .name')" - | wl-copy
bind = SUPER+SHIFT,S,spawn_shell,$HOME/.config/mango/scripts/screenshot freeze-region
bind=ALT+SHIFT,S,spawn_shell,$HOME/.config/mango/scripts/screenshot output
bind=ALT+CTRL,S,spawn_shell,$HOME/.config/mango/scripts/screenshot window
# swap window
bind=SUPER+SHIFT,Up,exchange_client,up

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
mkdir -p "$HOME/Pictures/Screenshots"
filepath="$HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).png"
case "${1:-fullscreen}" in
region)
g=$(slurp -d); [ -z "$g" ] && exit 1
grim -g "$g" - | wl-copy ;;
window)
g=$(mmsg get focusing-client | jq -r '"\(.x),\(.y) \(.width)x\(.height)"')
[ -z "$g" ] && exit 1
grim -g "$g" - | wl-copy ;;
freeze)
p=$(mktemp -u).fifo; mkfifo "$p"
wayfreeze --after-freeze-timeout 100 --after-freeze-cmd "echo > $p" & wp=$!
read -r < "$p"; grim - | wl-copy
kill "$wp" 2>/dev/null; rm -f "$p" ;;
freeze-region)
p=$(mktemp -u).fifo; mkfifo "$p"
wayfreeze --after-freeze-timeout 100 --after-freeze-cmd "echo > $p" & wp=$!
read -r < "$p"; g=$(slurp -d)
if [ -z "$g" ]; then kill "$wp" 2>/dev/null; rm -f "$p"; exit 1; fi
grim -g "$g" - | wl-copy
kill "$wp" 2>/dev/null; rm -f "$p" ;;
*) grim - | wl-copy;;
esac