diff --git a/install.sh b/install.sh index 0b0b017..cd3cdfa 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,26 @@ #!/bin/sh + _user_id=$(id -u) -if ! [ "$_user_id" -eq 0 ] ; then - echo "pacman-update-count.sh: insufficient priviliges: must be run as root" +if [ "$_user_id" -eq 0 ] ; then + echo "pacman-update-count.sh: error - must be run as normal user, not root" exit 1 fi -cp ./notify-updates /usr/local/bin/ -cp ./pacman-update-count /usr/local/bin/ +sudo cp ./notify-updates /usr/local/bin/ +sudo cp ./pacman-update-count /usr/local/bin/ + +sudo cp ./pacman-update-count.* /etc/systemd/system/ + +mkdir -p ~/.config/systemd/user +cp ./update-notifier.* ~/.config/systemd/user + +sudo systemctl daemon-reload + +sudo systemctl enable pacman-update-count.timer +sudo systemctl start pacman-update-count.timer + +systemctl --user enable update-notifier.timer +systemctl --user start update-notifier.timer + diff --git a/pacman-update-count.service b/pacman-update-count.service new file mode 100644 index 0000000..75815d6 --- /dev/null +++ b/pacman-update-count.service @@ -0,0 +1,9 @@ +[Unit] +Description=Update package update count (used by update-notifier) + +[Service] +ExecStart=/usr/local/bin/pacman-update-count + +[Install] +WantedBy=default.target + diff --git a/pacman-update-count.timer b/pacman-update-count.timer new file mode 100644 index 0000000..1fcf5a0 --- /dev/null +++ b/pacman-update-count.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Periodically run pacman-update-count + +[Timer] +OnBootSec=55minutes +OnActiveSec=1sec +OnUnitActiveSec=110minutes + +[Install] +WantedBy=timers.target diff --git a/update-notifier.service b/update-notifier.service new file mode 100644 index 0000000..bc4445f --- /dev/null +++ b/update-notifier.service @@ -0,0 +1,9 @@ +[Unit] +Description=Notify when updates are available + +[Service] +ExecStart=/usr/local/bin/notify-updates -n + +[Install] +WantedBy=default.target + diff --git a/update-notifier.timer b/update-notifier.timer new file mode 100644 index 0000000..d83d3ab --- /dev/null +++ b/update-notifier.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Periodically run update-notifier + +[Timer] +OnBootSec=1hour +OnActiveSec=1sec +OnUnitActiveSec=2hours + +[Install] +WantedBy=timers.target