update-report script

This commit is contained in:
nomadics9 2024-11-03 01:40:44 +03:00
parent 7f36be9690
commit 1ae049d8ed

View file

@ -1,3 +1,4 @@
output=$(nix store diff-closures $(ls -d /nix/var/nix/profiles/* | tail -2) | sed -r "s/\x1B\[[0-9;]*[mK]//g")
# Replace newline characters with spaces for a more horizontal notification
@ -17,9 +18,35 @@ formatted_output=$(echo "$output" | awk '
size_mib = size_kib / 1024
size_mib_rounded = (size_mib >= 1) ? sprintf("%.0f", size_mib) "M" : size_kib "KiB"
# Create the formatted output line with special characters to make it stand out
printf "🔹 %s: %s +%s\n", package, version, size_mib_rounded
# Append each entry to the formatted output
formatted_output = formatted_output "🔹 " package ": " version " +" size_mib_rounded "\n"
}
} END {
# Output all entries once processing is complete
print formatted_output
}')
notify-send -u low -h string:x-mako-stack-tag:diff "💫 Updated Packages" "$formatted_output" -t 0 -u critical
chunk_size=5
echo "$formatted_output" | awk -v chunk_size="$chunk_size" '
{
lines[++count] = $0
if (count % chunk_size == 0) {
for (i = 1; i <= count; i++) {
printf "%s\n", lines[i]
}
printf "---\n"
count = 0
}
}
END {
if (count > 0) {
for (i = 1; i <= count; i++) {
printf "%s\n", lines[i]
}
}
}' | while IFS= read -r chunk; do
if [[ "$chunk" != "---" ]]; then
notify-send -u low -h string:x-mako-stack-tag:diff "💫 Updated Packages" "$chunk" -t 0 -u critical
fi
done