mirror of
https://github.com/G2-Games/welcome.sh.git
synced 2025-04-19 05:22:53 -05:00
Add timeout for update check, 5 seconds
This commit is contained in:
parent
05f0fd6ec8
commit
df5d43dea3
1 changed files with 51 additions and 33 deletions
18
welcome.sh
18
welcome.sh
|
@ -105,9 +105,11 @@ updates () {
|
||||||
fedora=0
|
fedora=0
|
||||||
brew=0
|
brew=0
|
||||||
flatpak=0
|
flatpak=0
|
||||||
|
chk=0
|
||||||
|
|
||||||
# Check for updates from different places... wonder if there's a better way
|
# Check for updates from different places... wonder if there's a better way
|
||||||
|
|
||||||
|
updchk () {
|
||||||
# Check for APT
|
# Check for APT
|
||||||
if command -v apt-get &> /dev/null; then
|
if command -v apt-get &> /dev/null; then
|
||||||
debian=$(apt-get -s dist-upgrade -V 2> /dev/null | grep '=>' | awk '{print$1}' | wc -l)
|
debian=$(apt-get -s dist-upgrade -V 2> /dev/null | grep '=>' | awk '{print$1}' | wc -l)
|
||||||
|
@ -140,11 +142,26 @@ updates () {
|
||||||
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
|
if command -v flatpak &> /dev/null && [ "$flatpakupd" = "on" ]; then
|
||||||
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
flatpak=$(flatpak remote-ls --updates 2> /dev/null | wc -l)
|
||||||
fi
|
fi
|
||||||
|
pkill -P $pid sleep
|
||||||
|
}
|
||||||
|
|
||||||
|
pid=$(echo $$)
|
||||||
|
updchk &
|
||||||
|
|
||||||
|
exec 3>&2
|
||||||
|
exec 2> /dev/null
|
||||||
|
sleep 5
|
||||||
|
chk=$(echo $?) &> /dev/null
|
||||||
|
exec 2>&3
|
||||||
|
exec 3>&-
|
||||||
|
|
||||||
# Add all update counts together
|
# Add all update counts together
|
||||||
updates=$(($debian + $arch + $fedora + $flatpak + $brew))
|
updates=$(($debian + $arch + $fedora + $flatpak + $brew))
|
||||||
|
|
||||||
# Check the update amounts and print them out
|
# Check the update amounts and print them out
|
||||||
|
if [ $chk -lt 1 ]; then
|
||||||
|
echo -en "Update check timed out. "
|
||||||
|
else
|
||||||
if [ $updates -eq 1 ]; then
|
if [ $updates -eq 1 ]; then
|
||||||
echo -en "You have ${NORM}1${NCOL} pending update. "
|
echo -en "You have ${NORM}1${NCOL} pending update. "
|
||||||
elif [ $updates -eq 0 ]; then
|
elif [ $updates -eq 0 ]; then
|
||||||
|
@ -152,6 +169,7 @@ updates () {
|
||||||
else
|
else
|
||||||
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
echo -en "You have ~${NORM}$updates${NCOL} pending updates. "
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#=====Random Color=====#
|
#=====Random Color=====#
|
||||||
|
|
Loading…
Reference in a new issue