-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Adds support for showing separate sections in the tooltip for different update sources (pacman, aur, devel).
--- waybar-updates.sh.orig
+++ waybar-updates.sh
@@ global vars
- formats[tooltip]="\t\t {\t :pacman}{\t :aur}{\t :dev}\n\n{}"
+ formats[tooltip]="{}" # now we’ll build our own tooltip with headers
@@ add new globals, before any functions
+ tooltip_pacman=""
+ tooltip_aur=""
+ tooltip_devel=""
@@ tooltip_append()
- tooltip_append() {
- [[ ${!1} -gt 0 ]] || return
-
- [[ -z $tooltip ]] || tooltip+="\n"
-
- tooltip+="${!2}"
-}
+ tooltip_append() {
+ local count_var=$1 list_var=$2
+ # only add if there are updates
+ [[ ${!count_var} -gt 0 ]] || return
+
+ case "$list_var" in
+ pacman_updates)
+ tooltip_pacman+="\n${!list_var}"
+ ;;
+ aur_updates)
+ tooltip_aur+="\n${!list_var}"
+ ;;
+ devel_updates)
+ tooltip_devel+="\n${!list_var}"
+ ;;
+ esac
+}
@@ send_output()
- if [[ ! $total_updates_count -gt 0 ]]; then
+ if (( total_updates_count == 0 )); then
json "" updated "$(gettext "waybar-updates" "System is up to date")" updated
return 1
fi
-
- for source in pacman aur devel; do
- tooltip_append "${source}_updates_count" "${source}_updates"
- done
-
- json "$(format text "$total_updates_count")" "$status" "$(format \
- tooltip "$(echo -e "$tooltip" | head -n "$packages_limit")" \
- )" "$status"
+ # build each section
+ tooltip_pacman_header="[ Pacman updates: ${pacman_updates_count}]"
+ tooltip_aur_header="[ AUR updates: ${aur_updates_count}]"
+ tooltip_devel_header="[ Devel updates: ${devel_updates_count}]"
+
+ # collect the raw lists
+ tooltip_pacman=""; tooltip_aur=""; tooltip_devel=""
+ tooltip_append pacman_updates_count pacman_updates
+ tooltip_append aur_updates_count aur_updates
+ if [ "$devel" = true ]; then
+ tooltip_append devel_updates_count devel_updates
+ fi
+
+ # assemble full tooltip, limiting lines
+ full_tooltip=""
+ [[ -n $tooltip_pacman ]] && full_tooltip+="$tooltip_pacman_header\n${tooltip_pacman}\n\n"
+ [[ -n $tooltip_aur ]] && full_tooltip+="$tooltip_aur_header\n${tooltip_aur}\n\n"
+ [[ -n $tooltip_devel ]] && full_tooltip+="$tooltip_devel_header\n${tooltip_devel}\n\n"
+ # trim trailing whitespace/newlines
+ full_tooltip=$(echo -e "$full_tooltip" | head -n $packages_limit)
+
+ json "$(format text "$total_updates_count")" "$status" "$full_tooltip" "$status"It's not my code (GPT helped me))), I tried it once and it works.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels