mirror of
https://github.com/Stunkymonkey/dotfiles.git
synced 2025-05-24 11:04:41 +02:00
[cron] adding all cron-scripts
This commit is contained in:
parent
c3b682b26f
commit
749a7f45af
3 changed files with 73 additions and 0 deletions
41
cron/blackcheck.py
Executable file
41
cron/blackcheck.py
Executable file
|
@ -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))
|
17
cron/borg-notify.sh
Executable file
17
cron/borg-notify.sh
Executable file
|
@ -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
|
15
cron/webcam.sh
Executable file
15
cron/webcam.sh
Executable file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue