diff --git a/cron/blackcheck.py b/cron/blackcheck.py new file mode 100755 index 0000000..1a41758 --- /dev/null +++ b/cron/blackcheck.py @@ -0,0 +1,41 @@ +from PIL import Image +from optparse import OptionParser +# import sys + +parser = OptionParser() +parser.add_option("-q", "--quiet", action="store_false", dest="verbose", + default=True, help="don't print status messages to stdout") +parser.add_option("-i", "--image", type="string", dest="imagename", + help="Name of Image") +parser.add_option("-d", "--diff", type="string", dest="diff", + default=0, help="maximum difference between Red, Green, Blue") + +(options, args) = parser.parse_args() + +if (options.imagename is None): + parser.error("no image entered") + +diff = int(options.diff) +img_path = options.imagename + + +def is_grey_scale(img_path): + try: + im = Image.open(img_path).convert('RGB') + except (FileNotFoundError): + print ("Image not found") + quit() + w, h = im.size + for i in range(w): + for j in range(h): + r, g, b = im.getpixel((i, j)) + if ((abs(r - g) > diff) & + (abs(r - b) > diff) & + (abs(b - g) > diff)): + return False + return True + +if (bool(options.verbose) == False): + is_grey_scale(img_path) +else: + print (is_grey_scale(img_path)) diff --git a/cron/borg-notify.sh b/cron/borg-notify.sh new file mode 100755 index 0000000..408f346 --- /dev/null +++ b/cron/borg-notify.sh @@ -0,0 +1,17 @@ +#!/bin/bash +## */10 * * * * cd ~/.dotfiles/cron/ && bash borg-notify.sh + +LAST=$(tail -1 ~/.borgbackup.log) + +DIF=$((($(date -d "now" +%s) - $(date -d $LAST +%s)) / 86400)) + +if [ $DIF -ge 7 ] ; then + export DISPLAY=:0 + for proc in $(pgrep -u $USER); do + if grep -z DBUS_SESSION_BUS_ADDRESS /proc/$proc/environ; then + export DBUS_SESSION_BUS_ADDRESS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$proc/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//')" + break + fi + done + notify-send -i drive-harddisk Borg-Backup "Your last backup was $DIF days ago.\nPlease make a new one." +fi diff --git a/cron/webcam.sh b/cron/webcam.sh new file mode 100755 index 0000000..1a19c96 --- /dev/null +++ b/cron/webcam.sh @@ -0,0 +1,15 @@ +#!/bin/bash +## 0 * * * * cd ~/.dotfiles/cron/ && bash webcam.sh +now=$(date +"%Y_%m_%d_%H_%M_%S") +path="$HOME/Pictures/hour-pics/" +size="1280x720" + +mkdir -p $path +streamer -q -f jpeg -s $size -o $path$now.jpeg -r 1 +grey="$(python3 ./blackcheck.py -i $path$now.jpeg -d 10)" +# echo $grey +if [ "$grey" = "True" ] ; then + # echo "Has to move" + mv $path$now.jpeg ${path}black/$now.jpeg +fi +exit 0