-
Notifications
You must be signed in to change notification settings - Fork 193
screenshot
mangowm does not include a built-in screenshot tool. This keeps the compositor lean. Instead, compose your own workflow from small Wayland utilities and bind them to keys;
| Tool | Purpose |
|---|---|
grim |
Capture the screen or a region to a file |
slurp |
Interactively select a region for grim
|
wl-copy |
Copy screenshots directly to the clipboard |
satty |
Annotate screenshots before saving |
wayfreeze |
Freeze the screen before capture |
Install the required with your package manager or from source.
grim writes to the file path you give it, but will not create missing directories. Create one first:
mkdir -p ~/Pictures/ScreenshotsAny directory works. ~/Pictures/Screenshots/ is just a convention.
Short, single-step commands can be placed directly in config.conf with spawn_shell.
No script file needed.
Captures the entire display.
bind=NONE,Print,spawn_shell,grim $HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).pngSelect an area with slurp before capturing.
bind=SHIFT,Print,spawn_shell,g=$(slurp -d) && [ -n "$g" ] && grim -g "$g" $HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).pngCaptures the full screen including the cursor.
bind=ALT,Print,spawn_shell,grim -c $HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).pngCaptures to a temporary file and copies the image to the clipboard; no file is saved.
bind=CTRL,Print,spawn_shell,f=$(mktemp -t screenshot-XXXXXX.png) && grim "$f" && wl-copy < "$f" && rm -f "$f"Captures and opens satty for drawing before saving.
bind=SUPER,Print,spawn_shell,f=$HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).png && grim "$f" && satty --filename "$f" --output-filename "$f" --actions-on-enter save-to-file --early-exitWhen a command involves multi-step logic, geometry parsing, FIFOs, or screen freezing,
move it into a script and invoke it with spawn instead of spawn_shell.
Create the scripts directory first:
mkdir -p ~/.config/mango/scripts/screenshotUses mmsg (ships with mango) to capture the focused window.
~/.config/mango/scripts/screenshot/window.sh:
#!/usr/bin/env bash
geometry=$(mmsg -x | awk '/x / {x=$3} /y / {y=$3} /width / {w=$3} /height / {h=$3} END {print x","y" "w"x"h}')
[ -z "$geometry" ] && exit 1
grim -g "$geometry" "$HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).png"bind=CTRL+SHIFT,Print,spawn,$HOME/.config/mango/scripts/screenshot/window.shFreezes the screen with wayfreeze before capturing.
~/.config/mango/scripts/screenshot/freeze.sh:
#!/usr/bin/env bash
pipe=$(mktemp -u).fifo
mkfifo "$pipe"
wayfreeze --after-freeze-timeout 100 --after-freeze-cmd "echo > $pipe" &
wayfreeze_pid=$!
read -r < "$pipe"
grim "$HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).png"
kill "$wayfreeze_pid" 2>/dev/null
rm -f "$pipe"bind=CTRL+SUPER,Print,spawn,$HOME/.config/mango/scripts/screenshot/freeze.shFreeze, then select a region with slurp. Cleans up on cancel.
~/.config/mango/scripts/screenshot/freeze-region.sh:
#!/usr/bin/env bash
pipe=$(mktemp -u).fifo
mkfifo "$pipe"
wayfreeze --after-freeze-timeout 100 --after-freeze-cmd "echo > $pipe" &
wayfreeze_pid=$!
read -r < "$pipe"
geometry=$(slurp -d)
if [[ -z "$geometry" ]]; then
kill "$wayfreeze_pid" 2>/dev/null
rm -f "$pipe"
exit 1
fi
grim -g "$geometry" "$HOME/Pictures/Screenshots/$(date +%Y%m%d%H%M%S).png"
kill "$wayfreeze_pid" 2>/dev/null
rm -f "$pipe"bind=SHIFT+SUPER,Print,spawn,$HOME/.config/mango/scripts/screenshot/freeze-region.shMake all three scripts executable:
chmod +x ~/.config/mango/scripts/screenshot/*.shPrefer fewer files? A single script with subcommands covers every mode above. Place it in the same directory and use it in place of the individual scripts.
~/.config/mango/scripts/screenshot/screenshot.sh:
#!/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" "$filepath" ;;
window)
g=$(mmsg -x | awk '/x / {x=$3} /y / {y=$3} /width / {w=$3} /height / {h=$3} END {print x","y" "w"x"h}')
[ -z "$g" ] && exit 1
grim -g "$g" "$filepath" ;;
freeze)
p=$(mktemp -u).fifo; mkfifo "$p"
wayfreeze --after-freeze-timeout 100 --after-freeze-cmd "echo > $p" & wp=$!
read -r < "$p"; grim "$filepath"
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" "$filepath"
kill "$wp" 2>/dev/null; rm -f "$p" ;;
annotate)
grim "$filepath"; satty --filename "$filepath" --output-filename "$filepath" --actions-on-enter save-to-file --early-exit ;;
*) grim "$filepath" ;;
esacMake the script executable:
chmod +x ~/.config/mango/scripts/screenshot/screenshot.shThen add the binds to config.conf:
bind=NONE,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh fullscreen
bind=SHIFT,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh region
bind=CTRL+SHIFT,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh window
bind=CTRL+SUPER,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh freeze
bind=SHIFT+SUPER,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh freeze-region
bind=SUPER,Print,spawn,$HOME/.config/mango/scripts/screenshot/screenshot.sh annotate