Skip to content

Commit

Permalink
- relabel functions
Browse files Browse the repository at this point in the history
- update comments
  • Loading branch information
trigg committed May 7, 2024
1 parent 3016e26 commit 848a866
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -193,29 +193,29 @@ invalid_option() {
icon_dir="/usr/share/icons/${name}"
[ -d "/usr/local/share/icons/${name}" ] && icon_dir="/usr/local/share/icons/${name}"

# Definition of the icon_checking function: Change icon to "checking"
icon_checking() {
# Definition of the state_checking function: Change state to "checking"
state_checking() {
echo "${name}_checking" > "${state_dir}/current_state"
}

# Definition of the icon_updates_available function: Change icon to "updates-available"
icon_updates_available() {
# Definition of the state_update_available function: Change state to "updates-available"
state_update_available() {
echo "${name}_updates-available" > "${state_dir}/current_state"
}

# Definition of the icon_installing function: Change icon to "installing"
icon_installing() {
# Definition of the state_installing function: Change state to "installing"
state_installing() {
echo "${name}_installing" > "${state_dir}/current_state"
}

# Definition of the icon_up_to_date function: Change icon to "up to date"
icon_up_to_date() {
# Definition of the state_up_to_date function: Change state to "up to date"
state_up_to_date() {
echo "${name}_up-to-date" > "${state_dir}/current_state"
}

# Definition of the check function: Check for available updates, change the icon accordingly and send a desktop notification containing the number of available updates
check() {
icon_checking
state_checking

if [ -n "${aur_helper}" ] && [ -n "${flatpak}" ]; then
update_available=$(checkupdates ; "${aur_helper}" -Qua ; flatpak update | sed -n '/^ 1./,$p' | awk '{print $2}' | grep -v '^$' | sed '$d')
Expand All @@ -233,7 +233,7 @@ check() {
fi

if [ -n "${update_available}" ]; then
icon_updates_available
state_update_available

if [ -n "${notif}" ]; then
if ! diff "${statedir}/current_updates_check" "${statedir}/last_updates_check" &> /dev/null; then
Expand All @@ -256,7 +256,7 @@ check() {
fi
fi
else
icon_up_to_date
state_up_to_date
fi

if [ -f "${statedir}/current_updates_check" ]; then
Expand All @@ -266,7 +266,7 @@ check() {

# Definition of the list_packages function: Display packages that are available for update and offer to apply them if there are
list_packages() {
icon_checking
state_checking
info_msg "$(eval_gettext "Looking for updates...\n")"

if [ -z "${no_version}" ]; then
Expand Down Expand Up @@ -303,14 +303,14 @@ list_packages() {
fi

if [ -z "${packages}" ] && [ -z "${aur_packages}" ] && [ -z "${flatpak_packages}" ]; then
icon_up_to_date
state_up_to_date
if [ -z "${list_option}" ]; then
info_msg "$(eval_gettext "No update available\n")"
else
exit 7
fi
else
icon_updates_available
state_update_available
if [ -z "${list_option}" ]; then
ask_msg "$(eval_gettext "Proceed with update? [Y/n]")"

Expand Down Expand Up @@ -393,14 +393,14 @@ list_news() {

# Definition of the update function: Update packages
update() {
icon_installing
state_installing

if [ -n "${packages}" ]; then
echo
main_msg "$(eval_gettext "Updating Packages...\n")"

if ! "${su_cmd}" pacman --color "${pacman_color_opt}" -Syu; then
icon_updates_available
state_update_available
echo
error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg
exit 5
Expand All @@ -412,7 +412,7 @@ update() {
main_msg "$(eval_gettext "Updating AUR Packages...\n")"

if ! "${aur_helper}" --color "${pacman_color_opt}" "${devel_flag[@]}" -Syu; then
icon_updates_available
state_update_available
echo
error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg
exit 5
Expand All @@ -424,13 +424,13 @@ update() {
main_msg "$(eval_gettext "Updating Flatpak Packages...\n")"

if ! flatpak update; then
icon_updates_available
state_update_available
error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg
exit 5
fi
fi

icon_up_to_date
state_up_to_date
echo
info_msg "$(eval_gettext "The update has been applied\n")"
}
Expand Down

0 comments on commit 848a866

Please sign in to comment.