1
0
mirror of https://github.com/eoli3n/dotfiles synced 2024-11-26 06:08:35 +01:00

fixed wc-l

This commit is contained in:
eoli3n 2020-12-23 16:28:38 +01:00
parent e54a7416df
commit 3c2fa7eb8b

@ -1,21 +1,18 @@
#!/bin/bash #!/bin/bash
pacman_check() { pacman_check() {
pac=$(checkupdates 2>/dev/null | wc -l) pac=$(checkupdates 2>/dev/null)
aur=$(trizen -Qua 2>/dev/null | wc -l) pac_count=$(wc -l <<< "$pac")
aur=$(trizen -Qua 2>/dev/null)
aur_count=$(wc -l <<< "$aur")
if [[ $pac -eq "0" ]] && [[ $aur -eq "0" ]] || [[ ! $pac =~ [0-9]+ ]] || [[ ! $aur =~ [0-9]+ ]] if [[ $pac_count -eq "0" ]] && [[ $aur_count -eq "0" ]] || [[ ! $pac_count =~ [0-9]+ ]] || [[ ! $aur_count =~ [0-9]+ ]]
then then
exit 0 exit 0
fi fi
if checkupdates | grep '^linux\ ' text="$pac <span foreground='#929292'></span> $aur"
then tooltip=$(awk -v ORS='\\n' '$0=$1' <<< "$pac$aur")
echo "$pac <span foreground='#ff5c57'></span> $aur"
else
#echo "$pac %{F#5b5b5b}%{F-} $aur"
echo "$pac <span foreground='#929292'></span> $aur"
fi
} }
xbps_check(){ xbps_check(){
@ -26,9 +23,9 @@ xbps_check(){
then then
exit 0 exit 0
fi fi
text="<span foreground='#929292'></span> $pkg_count" text="<span foreground='#929292'></span> $pkg_count"
tooltip=$(awk '$0=$1' ORS='\\n' <<< "$pkg") tooltip=$(awk -v ORS='\\n' '$0=$1' <<< "$pkg")
printf '{"text": "%s", "tooltip": "%s"}' "$text" "$tooltip"
} }
if grep -i "arch" /etc/os-release &>/dev/null if grep -i "arch" /etc/os-release &>/dev/null
@ -38,3 +35,6 @@ elif grep -i "void" /etc/os-release &>/dev/null
then then
xbps_check xbps_check
fi fi
# Print json
printf '{"text": "%s", "tooltip": "%s"}' "$text" "$tooltip"