diff --git a/cron/borg-notify.sh b/cron/borg-notify.sh deleted file mode 100755 index 4893bb6..0000000 --- a/cron/borg-notify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -## */10 * * * * ~/.dotfiles/cron/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/systemd/borg-notify-install.sh b/systemd/borg-notify-install.sh new file mode 100755 index 0000000..d6d4c9c --- /dev/null +++ b/systemd/borg-notify-install.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +cp borg-notify.service borg-notify.timer ~/.config/systemd/user/ +systemctl enable borg-notify.timer --user diff --git a/systemd/borg-notify.service b/systemd/borg-notify.service new file mode 100644 index 0000000..5adb94d --- /dev/null +++ b/systemd/borg-notify.service @@ -0,0 +1,6 @@ +[Unit] +Description=Borg-notification + +[Service] +ExecStart=/home/felix/.dotfiles/systemd/borg-notify.sh +Type=oneshot diff --git a/systemd/borg-notify.sh b/systemd/borg-notify.sh new file mode 100755 index 0000000..4e9ff36 --- /dev/null +++ b/systemd/borg-notify.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +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 + 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/systemd/borg-notify.timer b/systemd/borg-notify.timer new file mode 100644 index 0000000..e358bb9 --- /dev/null +++ b/systemd/borg-notify.timer @@ -0,0 +1,9 @@ +[Unit] +Description=10 min borg-notification + +[Timer] +OnBootSec=1min +OnUnitActiveSec=10min + +[Install] +WantedBy=timers.target