Taken screenshots on SwayWM

Talks about: , , , and

SwayWM uses can use a mixture of grim and slurp to take screenshots of their desktop. Place the following key binding in your Sway config:

# take screenshot of currently focused screen
bindsym $mod+Print exec /usr/bin/grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') $(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S.png')

# take screenshot of selection
bindsym $mod+Shift+p exec /usr/bin/grim -g "$(/usr/bin/slurp)" $(xdg-user-dir PICTURES)/$(date +'%Y-%m-%d-%H%M%S.png')