Skip to content

Commit

Permalink
[eos-update-notifier] added randomization to firing of the notifier t…
Browse files Browse the repository at this point in the history
…imer
  • Loading branch information
manuel-192 committed Oct 2, 2023
1 parent 5a4fb52 commit 8703d66
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
8 changes: 4 additions & 4 deletions eos-update-notifier/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pkgname=eos-update-notifier
pkgdesc="Software update notifier and 'news for you' for EndeavourOS users."
pkgver=23
pkgrel=13
pkgrel=14
arch=('any')
license=('GPL')
depends=(eos-bash-shared pacman-contrib xdg-utils libnotify)
Expand Down Expand Up @@ -34,16 +34,16 @@ source=(
$_url/$pkgname.service
$_url/checkupdatesext
)
sha512sums=('a064ced9673f405248043216566572adb9aa948a4ca5bc15523a38b684ae92cb67f1ff781f3693db4303e1159db4177487936ff6c898d8a7c087b313eb69ebfc'
'566f6cb295d3bc0af6ee85e33dde9df1a0cde9a043f501c99571db13b26394406a6d8017c7564a3e38ff5365f6dfe1e095b7c1f50674e85b2d9c8ef1a5c822b2'
sha512sums=('a74b78522dfda6fbac72c3de235c8b40590096895c3ff2e885b3a9fe5eaf6ed8a6257f98d953c6150dbe7738a873d76c09eb0c21842183ca962584dad46d8978'
'23e77fce832cbf5225e022ef61cef09fe1d367a802bd95d49f874673d1c27a7ce3a08321a739742b073595ea6ffc16e528bea76e351b9a6364bca7a8b3dc410b'
'd046e675f98a52b9c310e970c5a0b0bc92b08b60d55b9d39140516977e8a6ceb4b3f9d9b05d12fce377b5744f4563e5e66a86ceecafb57f5bd486f968dc57234'
'27acf7725d0e760b9dbc9d96e7dabf64339214163615155ae4fe2b4999c741e15590fc708866d830c584e321d7298d0ed5d0566adb6791c09c743289dbbebd6a'
'd5d4d92a9fd0d7a4425bb7000d208d717846ff30c2c31abac94c88840d3e8edc4862a6aacbb576330ff9d7644e63cf90e509caad629d9ed516f378e62b26e168'
'4c0debbea2fdbfbd86725494bdd5433adb1d3c586168e3cb24b9823501ccc25cdc594854963fb248b5c43a7449a2d348b067791adcea395879a47f3d5ff557f5'
'c33d879c3a0dd3309e633b15f6bde41543317131a2ab15b077f97f7532e88e2afb426ebd299e5d3309b6677e4fdea93b2452548c9904f219d5a5d43e87586157'
'a1e17d8f2f1579b000dacdc7a37be698c29528365d9e94d636ceffb3eb8346e16b4ff8ca04ce8ea35d9fff346fe548449d3609f3d448219eb5d89b2c3a5ac571'
'daa4868b0e2a554990b4091cade1e99f92cf1b450afa5bbe49183e622d53a3994f2227d5d8cf852e22a8c5781c7780433fbf529556131a8b48effe51b9e7e7e1'
'566f6cb295d3bc0af6ee85e33dde9df1a0cde9a043f501c99571db13b26394406a6d8017c7564a3e38ff5365f6dfe1e095b7c1f50674e85b2d9c8ef1a5c822b2'
'23e77fce832cbf5225e022ef61cef09fe1d367a802bd95d49f874673d1c27a7ce3a08321a739742b073595ea6ffc16e528bea76e351b9a6364bca7a8b3dc410b'
'd046e675f98a52b9c310e970c5a0b0bc92b08b60d55b9d39140516977e8a6ceb4b3f9d9b05d12fce377b5744f4563e5e66a86ceecafb57f5bd486f968dc57234'
'8238f98c85c3ed118a654361c30a945f7ce028206a03ffb3e41cfc208c646c16cd5fa23585ee4f1926b01be8409fec8183a2b81f6cb3a5d2566504fdb0f7f472')

Expand Down
12 changes: 9 additions & 3 deletions eos-update-notifier/eos-update-notifier
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,14 @@ Initialize() { # initialize service and timer for the current user
case "$arg" in
-conf | --conf)
# add any missing setting under [Timer] (in reverse order)
[ -n "$(grep ".*Persistent=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \Persistent=$persistent"
[ -n "$(grep ".*OnCalendar=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \OnCalendar=$oncalendar"
[ -n "$(grep ".*OnStartupSec=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \OnStartupSec=$onstartupsec"
[ -n "$(grep ".*RandomizedDelaySec=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \RandomizedDelaySec=$randomizeddelaysec"
[ -n "$(grep ".*Persistent=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \Persistent=$persistent"
[ -n "$(grep ".*OnCalendar=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \OnCalendar=$oncalendar"
[ -n "$(grep ".*OnStartupSec=" "$timer")" ] || sed -i "$timer" -e "/^\[Timer\]/a \OnStartupSec=$onstartupsec"

# remove possible old stuff
sed -i "$timer" -e "s|^# Persistent=true||"

# write new settings
case "${onstartupsec,,}" in
""|false) sed -E -i "$timer" -e "s|.*OnStartupSec=.*|# OnStartupSec=|" ;;
Expand Down Expand Up @@ -708,6 +713,7 @@ Main()
local oncalendar="$( grep ".*OnCalendar=" $configdir/$progname.timer 2>/dev/null | cut -d '=' -f 2)"
local onstartupsec="$(grep ".*OnStartupSec=" $configdir/$progname.timer 2>/dev/null | cut -d '=' -f 2)"
local persistent="$( grep ".*Persistent=" $configdir/$progname.timer 2>/dev/null | cut -d '=' -f 2)"
local -r randomizeddelaysec=10min

[ -n "$oncalendar" ] || oncalendar=daily
[ -n "$persistent" ] || persistent=false
Expand Down
7 changes: 4 additions & 3 deletions eos-update-notifier/eos-update-notifier.timer
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[Unit]
Description=EOS update notifier runs periodically (weekly) and soon after a reboot
Description=Runs EOS update notifier runs periodically.

[Timer]
OnStartupSec=300 seconds
# OnStartupSec=
OnCalendar=weekly
# Persistent=true
Persistent=false
RandomizedDelaySec=10min

[Install]
WantedBy=timers.target

0 comments on commit 8703d66

Please sign in to comment.