summaryrefslogtreecommitdiff
path: root/screenshot.sh
blob: 02dca781a8025ffdde67d41e8f949647f426be39 (plain)
    1 #!/usr/bin/env bash
    2 #
    3 # A simple screenshot script. Very handy for calling a specific from a window
    4 # manager using custom hotkeys (eg: i3)
    5 #
    6 # Requirements (X11):
    7 #   imagemagick
    8 #
    9 # Requirements (Wayland):
   10 #   slurp (for getting screenshot geometry)
   11 #   grim  (for taking the actual screenshot)
   12 #
   13 savepath=~/Pictures/screenshots/
   14 
   15 if [ ! -d "${savepath}" ]; then
   16 	mkdir -p "${savepath}"
   17 fi
   18 
   19 # Wait two seconds
   20 sleep 2
   21 
   22 # Get our file suffix
   23 date="$(date '+%Y%m%d-%H%M%S')"
   24 
   25 # And action!
   26 if [ -n "${WAYLAND_DISPLAY}" ]; then
   27   grim -g "$(slurp -w 4)" "${savepath}/screen.${date}.jpg"
   28 elif [ -n "${DISPLAY}" ]; then
   29   import "${savepath}/screen.${date}.jpg"
   30 else
   31   printf 'ERROR: Could not detect display manager\n'
   32   exit 1
   33 fi

Generated by cgit