Notification when connected to the internet

How can I get a notification when connected to the internet?

Do you mean to have an icon showing, like on Windows, whether the internet is accessible thru home firewall router or not ?

I have a modem from a satellite company.

If I understood correctly you are asking how to set up so that you get information on desktop pop-up you are connected to the network?

If so - you should open MENU ---> type in search bar "indicators" ---> open app "indicators" where you should access "Ayatana Indicators Settings" ---> on the left side there is "Notifications" and when you open them you can add app you want to see indications from and simply choose "NetworkManager" as it should be default on Mate for network management

It works on my 24.04.1 version, and I hope you will find what you asked for :grin:

2 Likes

Taking your question literally, there are no standard means to indicate the presence of the Internet connection.

System's indicator of a network connection status shows whether your computer is connected to a wired (Ethernet) or wireless (WiFi) network. That network usually is local 'last yard' network. It connects computer to modem or router which is in turn connected to provider which is connected to the Internet backbone or another provider... Finally, the fact that computer is connected to the 'last yard' network and can reach modem/router does not ensure that the Internet as such is available.

Actually, some Linux users try to monitor the Internet connectivity by pinging or retrieving pages from web-sites of their choice via hand-made scripts. You might want to have a look at the following links for some more detail:

4 Likes

Thanks. This results in an Invalid argument error.

I would like to play a sound if online. I know how to play the sound.

#!/usr/bin/bash

# Test for network conection
for interface in $(ls /sys/class/net/ | grep -v lo);
do
  if [[ $(cat /sys/class/net/$interface/carrier) = 1 ]]; then OnLine=1; fi
done
if ! [ $OnLine ]; then echo "Not Online" > /dev/stderr; exit; fi

cat: /sys/class/net/wlp2s0/carrier: Invalid argument
1 Like

Sorry, I can not help for I can not reproduce the error. The only proposal is that you do not check every interface status but select one for the purpose.

ugn@evm:~$ cat tst.sh
for interface in $(ls /sys/class/net/ | grep -v lo);
do
  if [[ $(cat /sys/class/net/$interface/carrier) = 1 ]]; then OnLine=1; fi
done
if ! [ $OnLine ]; then echo "Not Online" > /dev/stderr; exit; fi
ugn@evm:~$ ./tst.sh
ugn@evm:~$ 
ugn@evm:~$ ls /sys/class/net | grep -v lo
enp2s0f1
wlp3s0
ugn@evm:~$ cat /sys/class/net/enp2s0f1/carrier
0
ugn@evm:~$ cat /sys/class/net/wlp3s0/carrier
1
ugn@evm:~$ 

2 Likes

This is good enough.

for i in {1..5}; do
    ping -i0.5 -c3 -w3 google.com ||
        {
            sleep 5
            continue
        }

    aplay /home/andy/My_Sounds/Relax_6_Seconds.wav
    break
done
1 Like

In addition to what @Alarik has suggested, you can also right click on either panel and select the MATE Netspeed App:

3 Likes