How to autostart a program after network connection on Ubuntu?
How can I autostart chromium in lubuntu after a network connection?
I tried to add it ~/.config/autostart/
but chromium started before wifi connection so an error page is displayed.
I've been searched through Google but still cant find any solution.
lubuntu
add a comment |
How can I autostart chromium in lubuntu after a network connection?
I tried to add it ~/.config/autostart/
but chromium started before wifi connection so an error page is displayed.
I've been searched through Google but still cant find any solution.
lubuntu
add a comment |
How can I autostart chromium in lubuntu after a network connection?
I tried to add it ~/.config/autostart/
but chromium started before wifi connection so an error page is displayed.
I've been searched through Google but still cant find any solution.
lubuntu
How can I autostart chromium in lubuntu after a network connection?
I tried to add it ~/.config/autostart/
but chromium started before wifi connection so an error page is displayed.
I've been searched through Google but still cant find any solution.
lubuntu
lubuntu
edited Nov 16 '11 at 11:04
Diogo
22.1k57132211
22.1k57132211
asked Nov 16 '11 at 10:42
user998661user998661
234
234
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I don't know an elegant way, but here's an approach that should work.
Write a script that tests to see if you're online. If not, sleep for awhile and then loop back to test again. When you come online, start chrome and exit, etc.. Put that script in your autostart directory.
In bash, the wait command is sleep. It takes an argument of the number of seconds you want to wait. It keeps your script from testing too often and using up resources.
The trick is to figure out if you're online. One way to do that is to do something small that will fail if you're not online. Below is a hack that should be enough to get you started (if you know bash). I found the wget command trick on the web somewhere and I'm not sure exactly what it does, but it's quick and it works.
You'll have to substitute your path for chrome.
The ampersand at the end of the chrome line causes chrome to execute in the background so your script won't hang on that line until chrome exits. It will continue and terminate normally, leaving chrome running on its own.
If you want to get fancy, there's a way to save the process id of the task to a file, etc., so you can easily find it and kill it later if you decide you don't want chrome to start when you come online in a particular session. But, that's a bit beyond the scope of your question. (and I don't remember how to do it ;) )
#!/bin/bash
function online {
## Test if online - prototype code
wget -q -O /dev/null --timeout=5 http://udc.msn.com/c.gif
return $?
}
until online
do
sleep 5
done
/opt/google/chrome/google-chrome &
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
add a comment |
I think the following should work but I am assuming you set the path to ~/.config
in your ~/.bashrc
Make sure you have the paths of your bashrc set like this
export PATH=$PATH:$HOME/.config:/other/stuff
instead of
export PATH=$HOME/.config:/other/stuff:$PATH
where $PATH
is your system wide PATH settings - you are ensuring the autostart files in /etc/xdg/autostart
are read before your home settings when you login.
add a comment |
Working example...
#!/bin/bash
function online {
## Test if online - prototype code
ping -c 1 google.com
return $?
}
until online
do
sleep 5
done
vmware-view %u --nonInteractive &
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f358024%2fhow-to-autostart-a-program-after-network-connection-on-ubuntu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't know an elegant way, but here's an approach that should work.
Write a script that tests to see if you're online. If not, sleep for awhile and then loop back to test again. When you come online, start chrome and exit, etc.. Put that script in your autostart directory.
In bash, the wait command is sleep. It takes an argument of the number of seconds you want to wait. It keeps your script from testing too often and using up resources.
The trick is to figure out if you're online. One way to do that is to do something small that will fail if you're not online. Below is a hack that should be enough to get you started (if you know bash). I found the wget command trick on the web somewhere and I'm not sure exactly what it does, but it's quick and it works.
You'll have to substitute your path for chrome.
The ampersand at the end of the chrome line causes chrome to execute in the background so your script won't hang on that line until chrome exits. It will continue and terminate normally, leaving chrome running on its own.
If you want to get fancy, there's a way to save the process id of the task to a file, etc., so you can easily find it and kill it later if you decide you don't want chrome to start when you come online in a particular session. But, that's a bit beyond the scope of your question. (and I don't remember how to do it ;) )
#!/bin/bash
function online {
## Test if online - prototype code
wget -q -O /dev/null --timeout=5 http://udc.msn.com/c.gif
return $?
}
until online
do
sleep 5
done
/opt/google/chrome/google-chrome &
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
add a comment |
I don't know an elegant way, but here's an approach that should work.
Write a script that tests to see if you're online. If not, sleep for awhile and then loop back to test again. When you come online, start chrome and exit, etc.. Put that script in your autostart directory.
In bash, the wait command is sleep. It takes an argument of the number of seconds you want to wait. It keeps your script from testing too often and using up resources.
The trick is to figure out if you're online. One way to do that is to do something small that will fail if you're not online. Below is a hack that should be enough to get you started (if you know bash). I found the wget command trick on the web somewhere and I'm not sure exactly what it does, but it's quick and it works.
You'll have to substitute your path for chrome.
The ampersand at the end of the chrome line causes chrome to execute in the background so your script won't hang on that line until chrome exits. It will continue and terminate normally, leaving chrome running on its own.
If you want to get fancy, there's a way to save the process id of the task to a file, etc., so you can easily find it and kill it later if you decide you don't want chrome to start when you come online in a particular session. But, that's a bit beyond the scope of your question. (and I don't remember how to do it ;) )
#!/bin/bash
function online {
## Test if online - prototype code
wget -q -O /dev/null --timeout=5 http://udc.msn.com/c.gif
return $?
}
until online
do
sleep 5
done
/opt/google/chrome/google-chrome &
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
add a comment |
I don't know an elegant way, but here's an approach that should work.
Write a script that tests to see if you're online. If not, sleep for awhile and then loop back to test again. When you come online, start chrome and exit, etc.. Put that script in your autostart directory.
In bash, the wait command is sleep. It takes an argument of the number of seconds you want to wait. It keeps your script from testing too often and using up resources.
The trick is to figure out if you're online. One way to do that is to do something small that will fail if you're not online. Below is a hack that should be enough to get you started (if you know bash). I found the wget command trick on the web somewhere and I'm not sure exactly what it does, but it's quick and it works.
You'll have to substitute your path for chrome.
The ampersand at the end of the chrome line causes chrome to execute in the background so your script won't hang on that line until chrome exits. It will continue and terminate normally, leaving chrome running on its own.
If you want to get fancy, there's a way to save the process id of the task to a file, etc., so you can easily find it and kill it later if you decide you don't want chrome to start when you come online in a particular session. But, that's a bit beyond the scope of your question. (and I don't remember how to do it ;) )
#!/bin/bash
function online {
## Test if online - prototype code
wget -q -O /dev/null --timeout=5 http://udc.msn.com/c.gif
return $?
}
until online
do
sleep 5
done
/opt/google/chrome/google-chrome &
I don't know an elegant way, but here's an approach that should work.
Write a script that tests to see if you're online. If not, sleep for awhile and then loop back to test again. When you come online, start chrome and exit, etc.. Put that script in your autostart directory.
In bash, the wait command is sleep. It takes an argument of the number of seconds you want to wait. It keeps your script from testing too often and using up resources.
The trick is to figure out if you're online. One way to do that is to do something small that will fail if you're not online. Below is a hack that should be enough to get you started (if you know bash). I found the wget command trick on the web somewhere and I'm not sure exactly what it does, but it's quick and it works.
You'll have to substitute your path for chrome.
The ampersand at the end of the chrome line causes chrome to execute in the background so your script won't hang on that line until chrome exits. It will continue and terminate normally, leaving chrome running on its own.
If you want to get fancy, there's a way to save the process id of the task to a file, etc., so you can easily find it and kill it later if you decide you don't want chrome to start when you come online in a particular session. But, that's a bit beyond the scope of your question. (and I don't remember how to do it ;) )
#!/bin/bash
function online {
## Test if online - prototype code
wget -q -O /dev/null --timeout=5 http://udc.msn.com/c.gif
return $?
}
until online
do
sleep 5
done
/opt/google/chrome/google-chrome &
edited Nov 22 '11 at 0:44
answered Nov 22 '11 at 0:37
JoeJoe
503613
503613
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
add a comment |
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
Nice script. Works out of the box. Thanks a lot!
– BetaRide
Jan 2 '12 at 16:58
add a comment |
I think the following should work but I am assuming you set the path to ~/.config
in your ~/.bashrc
Make sure you have the paths of your bashrc set like this
export PATH=$PATH:$HOME/.config:/other/stuff
instead of
export PATH=$HOME/.config:/other/stuff:$PATH
where $PATH
is your system wide PATH settings - you are ensuring the autostart files in /etc/xdg/autostart
are read before your home settings when you login.
add a comment |
I think the following should work but I am assuming you set the path to ~/.config
in your ~/.bashrc
Make sure you have the paths of your bashrc set like this
export PATH=$PATH:$HOME/.config:/other/stuff
instead of
export PATH=$HOME/.config:/other/stuff:$PATH
where $PATH
is your system wide PATH settings - you are ensuring the autostart files in /etc/xdg/autostart
are read before your home settings when you login.
add a comment |
I think the following should work but I am assuming you set the path to ~/.config
in your ~/.bashrc
Make sure you have the paths of your bashrc set like this
export PATH=$PATH:$HOME/.config:/other/stuff
instead of
export PATH=$HOME/.config:/other/stuff:$PATH
where $PATH
is your system wide PATH settings - you are ensuring the autostart files in /etc/xdg/autostart
are read before your home settings when you login.
I think the following should work but I am assuming you set the path to ~/.config
in your ~/.bashrc
Make sure you have the paths of your bashrc set like this
export PATH=$PATH:$HOME/.config:/other/stuff
instead of
export PATH=$HOME/.config:/other/stuff:$PATH
where $PATH
is your system wide PATH settings - you are ensuring the autostart files in /etc/xdg/autostart
are read before your home settings when you login.
answered Nov 30 '13 at 17:00
MagpieMagpie
1211110
1211110
add a comment |
add a comment |
Working example...
#!/bin/bash
function online {
## Test if online - prototype code
ping -c 1 google.com
return $?
}
until online
do
sleep 5
done
vmware-view %u --nonInteractive &
add a comment |
Working example...
#!/bin/bash
function online {
## Test if online - prototype code
ping -c 1 google.com
return $?
}
until online
do
sleep 5
done
vmware-view %u --nonInteractive &
add a comment |
Working example...
#!/bin/bash
function online {
## Test if online - prototype code
ping -c 1 google.com
return $?
}
until online
do
sleep 5
done
vmware-view %u --nonInteractive &
Working example...
#!/bin/bash
function online {
## Test if online - prototype code
ping -c 1 google.com
return $?
}
until online
do
sleep 5
done
vmware-view %u --nonInteractive &
answered Feb 5 at 19:56
user994545user994545
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f358024%2fhow-to-autostart-a-program-after-network-connection-on-ubuntu%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown