#!/usr/bin/env bash # # A simple screenshot script. Very handy for calling a specific from a window # manager using custom hotkeys (eg: i3) # # Requirements (X11): # imagemagick # # Requirements (Wayland): # slurp (for getting screenshot geometry) # grim (for taking the actual screenshot) # savepath=~/Pictures/screenshots/ if [ ! -d "${savepath}" ]; then mkdir -p "${savepath}" fi # Wait two seconds sleep 2 # Get our file suffix date="$(date '+%Y%m%d-%H%M%S')" # And action! if [ -n "${WAYLAND_DISPLAY}" ]; then grim -g "$(slurp -w 4)" "${savepath}/screen.${date}.jpg" elif [ -n "${DISPLAY}" ]; then import "${savepath}/screen.${date}.jpg" else printf 'ERROR: Could not detect display manager\n' exit 1 fi