1
0
Fork 0
dotfiles/.local/bin/statusbar/sb-packages

16 lines
499 B
Bash
Executable File

#!/bin/sh
if command -v pacman 1>/dev/null 2>&1; then
echo -n "$(pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/ /;s/^ 0$//g")"
fi
if command -v apt 1>/dev/null 2>&1; then
vals=$(apt upgrade -sy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9 ' | tr ' ' '\n' | grep '[0-9]\+' | xargs echo)
for i in $vals; do
[ $i != 0 ] && icon="\033[11m\033[10m"
print="$print$i/"
done
[ -n "$icon" ] && printf "$icon " && echo " $print" | sed 's/\/$//'
fi