#!/bin/bash
# Copyright 2017 Lucid Networks sloeckle
# Package Version 1.11-0 - Script Version 9

. /opt/nexp-tools/nexp-tools.lib

source /etc/nexp-tools/nexp-tools.conf
export DISPLAY=:0
export EMAIL=$HOSTNAME'@lucidnetworks.net'
time=$(date +"%m-%d-%Y_%T")
rand=$(od -N 4 -t uL -An /dev/urandom | tr -d " ")
systeminfo
dir=/tmp/$rand
mkdir $dir &>/dev/null
scrot -q 100 $dir/$time.png &>/dev/null
if [ $APPNOTIFICATION == true ]; then
	if test -z "$1"
	then
		echo $systeminfo | mutt -s "$HOSTNAME Screenshot @ $time" -a $dir/$time.png -- $APPMAILTO
	else
		echo $systeminfo | mutt -s "$HOSTNAME Screenshot @ $time" -a $dir/$time.png -- $APPMAILTO,$1
	fi
fi
rm -rf $dir &>/dev/null
