You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

15 lines
463 B

#!/bin/zsh
# Saved in ~/online-check.sh and in a cron job as:
# * * * * * ~/online-check.sh
# An online indicator, green for active connection, and red for not.
# It's done by a cronjob touching or removing a file to indicate
# status every minute, and the file is checked by the prompt.
local offline=`dig 8.8.8.8 +time=1 +short google.com A | grep -c "no servers could be reached"`
if [[ "$offline" == "0" ]]; then
rm ~/.offline
else
touch ~/.offline
fi