How to Take Screenshots in Hyprland

Contents

Preface

Taking screenshots in Hyprland is straightforward, it just takes a few small tools.
This post starts with a region screenshot to the clipboard and adds saving and annotating on top.


The tools

  • grim - Screenshot utility for Wayland
  • slurp - Region selection tool for Wayland compositors
  • wl-clipboard - Clipboard utilities for Wayland
  • swappy - Annotation tool, only needed for the last part
sudo pacman -S grim slurp wl-clipboard swappy

Region to the clipboard

I use the PRINT key as my screenshot hotkey.
Add the following to your hyprland.conf:

bind = , PRINT, exec, grim -g "$(slurp)" - | wl-copy

This lets you select a region on the screen and copies the screenshot to your clipboard.


Saving to a file

For screenshots you want to keep, a small script saves them with a timestamp and copies them too:

mkdir -p ~/.local/bin
nano ~/.local/bin/screenshot
#!/bin/bash
dir=~/Pictures/Screenshots
mkdir -p "$dir"
file="$dir/$(date +%Y-%m-%d_%H-%M-%S).png"

if [ "$1" = "region" ]; then
  geometry=$(slurp) || exit 0
  grim -g "$geometry" "$file"
else
  grim "$file"
fi

wl-copy < "$file"
chmod +x ~/.local/bin/screenshot
Info
slurp exits with an error when you cancel the selection with Esc, so the script just stops instead of saving an empty file.

The binds:

bind = SHIFT, PRINT, exec, ~/.local/bin/screenshot region
bind = CTRL, PRINT, exec, ~/.local/bin/screenshot

SHIFT+PRINT saves a region, CTRL+PRINT the whole screen.


Annotating with swappy

To draw arrows, boxes or text on a screenshot before sharing it:

bind = $mainMod, PRINT, exec, grim -g "$(slurp)" - | swappy -f -

Select a region and swappy opens with it.
From there you can copy the result to the clipboard or save it.

Cheers.