Skip to content

Commit

Permalink
feat: Add the NoNotification option to arch-update.conf (#302)
Browse files Browse the repository at this point in the history
Add the `NoNotification` option in the `arch-update.conf` configuration file to disable desktop notification (the systray icon still acts as a visual indicator for available updates).

Closes #297
  • Loading branch information
Antiz96 authored Jan 21, 2025
1 parent c6ed5d8 commit 39b0efc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions doc/man/arch-update.conf.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Options are case sensitive, so capital letters have to be respected.
*NoVersion*
Do not show versions changes for packages when listing pending updates (including when using the `-l / --list` option, see the *arch-update*(1) man page for more details).

*NoNotification*
Do not send desktop notifications.

*NewsNum=[Num]*
Number of Arch news to display before updating and with the `-n / --news` option (see the *arch-update*(1) man page for more details). Defaults to 5.

Expand Down
3 changes: 3 additions & 0 deletions doc/man/fr/arch-update.conf.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Les options sont sensibles à la casse, les majuscules doivent donc être respec
*NoVersion*
Ne pas afficher les modifications de versions des paquets lors du listing des mises à jour en attente (y compris lors de l'utilisation de l'option `-l / --list`, voir la page de manuel *arch-update*(1) pour plus de détails).

*NoNotification*
Ne pas envoyer de notifications de bureau.

*NewsNum=[Num]*
Nombre de Arch news à afficher avant la mise à jour et avec l'option `-n / --news` (voir la page de manuel *arch-update*(1) pour plus de détails). La valeur par défaut est 5.

Expand Down
1 change: 1 addition & 0 deletions res/config/arch-update.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#NoColor
#NoVersion
#NoNotification
#NewsNum=5
#AURHelper=paru
#PrivilegeElevationCommand=sudo
Expand Down
12 changes: 5 additions & 7 deletions src/lib/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ if [ -n "${no_version}" ]; then
update_available=$(echo "${update_available}" | awk '{print $1}')
fi

if [ -n "${notif}" ]; then
# shellcheck disable=SC2154
echo "${update_available}" > "${statedir}/current_updates_check"
sed -i '/^\s*$/d' "${statedir}/current_updates_check"
sed -ri 's/\x1B\[[0-9;]*m//g' "${statedir}/current_updates_check"
fi
# shellcheck disable=SC2154
echo "${update_available}" > "${statedir}/current_updates_check"
sed -i '/^\s*$/d' "${statedir}/current_updates_check"
sed -ri 's/\x1B\[[0-9;]*m//g' "${statedir}/current_updates_check"

if [ -n "${update_available}" ]; then
icon_updates-available

if [ -n "${notif}" ]; then
if [ -n "${notif}" ] && [ -z "${no_notification}" ]; then
if ! diff "${statedir}/current_updates_check" "${statedir}/last_updates_check" &> /dev/null; then
update_number=$(wc -l "${statedir}/current_updates_check" | awk '{print $1}')
# shellcheck disable=SC2154
Expand Down
4 changes: 4 additions & 0 deletions src/lib/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ if [ -f "${config_file}" ]; then
# shellcheck disable=SC2034
no_version=$(grep -Eq '^[[:space:]]*NoVersion[[:space:]]*$' "${config_file}" 2> /dev/null && echo "true")

# Check the "NoNotification" option in arch-update.conf
# shellcheck disable=SC2034
no_notification=$(grep -Eq '^[[:space:]]*NoNotification[[:space:]]*$' "${config_file}" 2> /dev/null && echo "true")

# Check the "NewsNum" option in arch-update.conf
# shellcheck disable=SC2034
news_num=$(grep -E '^[[:space:]]*NewsNum[[:space:]]*=[[:space:]]*[1-9][0-9]*[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]')
Expand Down

0 comments on commit 39b0efc

Please sign in to comment.