cron/webcam*: added systemd-files & made script more readable

This commit is contained in:
Felix Buehler 2017-04-17 14:50:26 +02:00
parent e3363f1f4c
commit 71298adbeb
4 changed files with 25 additions and 7 deletions

4
cron/webcam-install.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
cp webcam.service webcam.timer ~/.config/systemd/user/
systemctl enable webcam.timer --user

6
cron/webcam.service Normal file
View file

@ -0,0 +1,6 @@
[Unit]
Description=Webcam script
[Service]
ExecStart=/home/felix/.dotfiles/cron/webcam.sh
Type=oneshot

View file

@ -1,15 +1,14 @@
#!/bin/bash #!/bin/bash
## 0 * * * * cd ~/.dotfiles/cron/ && bash webcam.sh ## 0 * * * * ~/.dotfiles/cron/webcam.sh
now=$(date +"%Y_%m_%d_%H_%M_%S") now=$(date +"%Y_%m_%d_%H_%M_%S")
path="$HOME/Pictures/hour-pics/" path="$HOME/Pictures/hour-pics"
size="1280x720" size="1280x720"
basename=$(dirname $(readlink -f $0))
mkdir -p $path mkdir -p $path
streamer -q -f jpeg -s $size -o $path$now.jpeg -r 1 streamer -q -f jpeg -s $size -o $path/$now.jpeg -r 1
grey="$(python3 $(dirname $(readlink -f $0))/blackcheck.py -i $path$now.jpeg -d 10)" grey="$(python3 $basename/blackcheck.py -i $path/$now.jpeg -d 10)"
# echo $grey
if [ "$grey" = "True" ] ; then if [ "$grey" = "True" ] ; then
# echo "Has to move" mv $path/$now.jpeg $path/black/$now.jpeg
mv $path$now.jpeg ${path}black/$now.jpeg
fi fi
exit 0 exit 0

9
cron/webcam.timer Normal file
View file

@ -0,0 +1,9 @@
[Unit]
Description=1hour webcam-timer
[Timer]
OnCalendar=*:0
Unit=webcam.target
[Install]
WantedBy=webcam.target