diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index bae77b8..2caad72 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -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() { - cp -f "${icon_dir}/${name}_checking.svg" "${icon_dir}/${name}.svg" || exit 3 +# Definition of the state_checking function: Change state to "checking" +state_checking() { + echo "${name}_checking" > "${statedir}/current_state" } -# Definition of the icon_updates_available function: Change icon to "updates-available" -icon_updates_available() { - cp -f "${icon_dir}/${name}_updates-available.svg" "${icon_dir}/${name}.svg" || exit 3 +# Definition of the state_updates_available function: Change state to "updates-available" +state_updates_available() { + echo "${name}_updates-available" > "${statedir}/current_state" } -# Definition of the icon_installing function: Change icon to "installing" -icon_installing() { - cp -f "${icon_dir}/${name}_installing.svg" "${icon_dir}/${name}.svg" || exit 3 +# Definition of the state_installing function: Change state to "installing" +state_installing() { + echo "${name}_installing" > "${statedir}/current_state" } -# Definition of the icon_up_to_date function: Change icon to "up to date" -icon_up_to_date() { - cp -f "${icon_dir}/${name}_up-to-date.svg" "${icon_dir}/${name}.svg" || exit 3 +# Definition of the state_up_to_date function: Change state to "up to date" +state_up_to_date() { + echo "${name}_up-to-date" > "${statedir}/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') @@ -233,7 +233,7 @@ check() { fi if [ -n "${update_available}" ]; then - icon_updates_available + state_updates_available if [ -n "${notif}" ]; then if ! diff "${statedir}/current_updates_check" "${statedir}/last_updates_check" &> /dev/null; then @@ -256,7 +256,7 @@ check() { fi fi else - icon_up_to_date + state_up_to_date fi if [ -f "${statedir}/current_updates_check" ]; then @@ -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 @@ -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_updates_available if [ -z "${list_option}" ]; then ask_msg "$(eval_gettext "Proceed with update? [Y/n]")" @@ -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_updates_available echo error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg exit 5 @@ -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_updates_available echo error_msg "$(eval_gettext "An error has occurred during the update process\nThe update has been aborted\n")" && quit_msg exit 5 @@ -424,13 +424,13 @@ update() { main_msg "$(eval_gettext "Updating Flatpak Packages...\n")" if ! flatpak update; then - icon_updates_available + state_updates_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")" }