···11+#!/bin/bash
22+33+Help() {
44+ echo "This script is a simple frontend to use grim and slurp in a more simplistic way."
55+ echo
66+ echo "Syntax: screenshot [-s|f|h]"
77+ echo "options:"
88+ echo "s Select a portion of the screen and take a screenshot."
99+ echo "f Screenshot the full screen."
1010+ echo "h Display this help message."
1111+ echo
1212+}
1313+1414+if [ $# -eq 0 ]; then
1515+ Help
1616+ exit
1717+1818+fi
1919+2020+if [ ! -d $HOME/Pictures/screenshots ]; then
2121+ mkdir -p $HOME/Pictures/screenshots
2222+fi
2323+2424+SCREENSHOT_DATE=$(date +'%Y-%m-%d_%H.%M.%S')
2525+SCREENSHOT_PATH="$HOME/Pictures/screenshots/$SCREENSHOT_DATE.png"
2626+2727+while getopts ":hfs" option; do
2828+ case $option in
2929+ h) # displays help
3030+ Help
3131+ exit;;
3232+ f) # screenshot full screen
3333+ grim $SCREENSHOT_PATH
3434+ notify-send -i $SCREENSHOT_PATH "Screenshot" "New screenshot saved as $SCREENSHOT_DATE.png"
3535+ exit;;
3636+ s) # select a portion and screenshot
3737+ grim -g "$(slurp)" $SCREENSHOT_PATH
3838+ notify-send -i $SCREENSHOT_PATH "Screenshot" "New screenshot saved as $SCREENSHOT_DATE"
3939+ exit;;
4040+ \?) # catchall
4141+ Help
4242+ exit;;
4343+ esac
4444+done