#!/bin/bash

# A simple script to take screenshoot using scrot
# Then add date to the file name
# Then open the result instantly using default image viewer
# Need xdg-utils, mostly preinstalled
# Cheers! Addy

# 'screeny -f' to take a screenshot for current focused window only
if [[ $1 = "-f" ]]; then
    scrot 'Cheese_%y.%m.%-d_%H.%M.%S.png' --focused --border \
    -e 'mv $f ~/Pictures; xdg-open ~/Pictures/$f'

# 'screeny -s' to take a screenshot with selection by dragging a rectangle
elif [[ $1 = "-s" ]]; then
    scrot 'Cheese_%y.%m.%-d_%H.%M.%S.png' --select \
    -e 'mv $f ~/Pictures; xdg-open ~/Pictures/$f'

# 'screeny' only to take a screenshoot normally
else
    scrot 'Cheese_%y.%m.%-d_%H.%M.%S.png' \
    -e 'mv $f ~/Pictures; xdg-open ~/Pictures/$f'
fi
