aboutsummaryrefslogtreecommitdiffstats
path: root/bin/sshot.sh
blob: 426d3232974df87ddb5d3fe50f7a83ff3c9f05d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

readonly PRONAME="$(basename "${0}")";
readonly PROGDIR="$(readlink -f "$(dirname "${0}")")";
readonly ARGS="${@}";

call_scrot()
{
	local dst_dir="${1}"; shift;
    scrot '%Y-%m-%d-%T_$wx$h_scrot.png' -e 'mv $f '"${dst_dir}" ${@}
    notify-send "Screenshot saved to ${dst_dir}/$(ls -rt1 "${dst_dir}" | tail -1)"
}

main()
{
    if [ ${#} -eq 0 ];
	then
		>&2 echo "You must at least provide the path of the directory where "
		>&2 echo "screenshots will be saved"
		exit 1
	fi

	call_scrot ${@};
}

main ${ARGS}
exit 0