How can I launch Firefox when there is internet connectivity ?
Sorry, I am a little shaky.
Do I make sense ?
How can I launch Firefox when there is internet connectivity ?
Sorry, I am a little shaky.
Do I make sense ?
If the above is what you actually meant then you can launch Firefox:
From a panel launcher if you chose to put one there
From a desktop launcher if you chose to put one there
If you use a dock then from a launcher if you chose to put one there
From the launcher in the Applications>Internet menu
By typing Firefox in a terminal
You do not understand what I am wanting.
I will try to think of another way to explain it.
I don’t have a clue what you mean. You want Internet connectivity when you launch a browser. Their is no reason Firefox would stop your connectivity.
Did you mess with your settings>Network Settings>Connection Settings?
I use a different Icon set, what are you trying to show us, the network is connected or the network is down with your drawing to your top panel?
This checks if there is an internet connection.
I would like it to start Firefox.
bash
This is what I have so far.
ping -c 4 google.com
if [ condition ]
then
Commands to execute if the condition is true
firefox
fi
If I am interpreting your question correctly:
You want to start Firefox automatically at login, but only on the condition that there is Internet connectivity at login.
Unfortunately I won’t be of much help, as I only know enough programming (if you can call it that) to edit config files (of picom, bashrc, etc.).
Am I correct in this interpretation? If so, I’m sure one of the other, much more skilled people than myself can be of help.
Jaymo
PING google.com (172.217.166.110) 56(84) bytes of data.
64 bytes from maa05s09-in-f14.1e100.net (172.217.166.110): icmp_seq=1 ttl=49 time=46.9 ms
Here are some things that might help you understand.
This can be used to determine if you have internet connection.
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 46.923/46.923/46.923/0.000 ms
if [ condition ]; then
firefox
fi
try this oneliner:
while ! ping -c 1 google.com ; do sleep 10 ; done ; firefox
Thanks.
I will do a search for how to run your "one liner" when my computer returns from being suspended.
It should be similar to this script.
(I remove the # symbols to avoid the gigantic fonts.
!/bin/sh
Backup files to maxtor drive before the computer has been suspended
Put this in /lib/systemd/system-sleep/case "$1" in
pre)
logger Files being backed up to Maxtor drive.
/home/andy/bin/Backup_Ubuntu_Mate.sh
logger done with backup, going to sleep.
;;
post)
logger waking up from sleep.
;;
esac
If you put Thom's (@tkn) oneliner in an rc script, it will run at boot and loop until it gets the required connection.
But ... that may not be successful unless you also add a condition to verify that your login Display session is actually open and that the window has a desktop to open into.
I put together the script you can
/etc/rc.local
Script:
#!/bin/sh
networkConnected()
{
# CONDITION: Return Code = 0
ping -c 1 google.com >/dev/null 2>&1
echo $?
}
while [ $(networkConnected) != "0" ]
do
sleep 10
done
displayOpen()
{
# CONDITION: /usr/lib/xorg/Xorg -dpms -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
ps -ef | grep '[-]core :0'
}
while [ -z "$(displayOpen)" ]
do
sleep 10
done
#echo "clear to start Firefox"
firefox
That will run at boot time and continue until you desktop is available. Just make sure it is executable.
Thanks for the work you did.
What is this?
/etc/rc.local
I want Firefox to start when my computer returns from a sleep state.
I do not want Firefox running all the time.
I think it has some memory leaks or whatever when left open for a long while.
I will put your code in my Ubuntu_Tips file.
Update: What if I put the script in my Startup Programs.
And add a sleep 30 seconds in the script?
I will try it now.
I don't know how to manage the sleep state (Suspend and restore from swap space). I've tried many times and never got it to recover, so I've abandoned that goal for now.
Someone else will need to guide you for that scenario.