An `/etc/network/if-up.d` script runs, but doesn't launch GUI apps (e.g. firefox-esr)
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I need to start firefox-esr
once the network is available.
Here's what I've got:
sudo tee "/etc/network/if-up.d/upif" > /dev/null << EOFBOOT
#!/bin/bash
DISPLAY=":0"
if [[ "$IFACE" = "eth0" || "$IFACE" = "wlan0" ]]; then
echo "$(date) $IFACE" >> /var/log/upif
firefox-esr &
fi
EOFBOOT
sudo chmod +x "/etc/network/if-up.d/upif"
I am getting the date and the interface name in my log file, which means the script runs, but firefox-esr
doesn't start.
What I've tried:
- adding
DISPLAY=":0"
grep -inR "firefox" /var/log
- using full path to executable, i.e.
/usr/bin/firefox-esr
- using
sudo firefox-esr &
- removing the trailing
&
Nothing helped. However, if I put IFACE="eth0"
below the shebang and then run sudo /etc/network/if-up.d/upif
manually, that exact script you see above does the job and starts firefox.
I am not sure what's the problem there. Spent few hours on it already. Please help!
This is 2018-06-27-raspbian-stretch-lite
running Debian 9.4.
P.S. Also I initially had logic checking whether Firefox already runs before attempting to start it, but once I realised Firefox isn't launched at all, I removed it
UPDATE Found a similar problem: Start a GUI in NetworkManager if-up.d script
debian raspberry-pi raspbian firefox gui
add a comment |Â
up vote
2
down vote
favorite
I need to start firefox-esr
once the network is available.
Here's what I've got:
sudo tee "/etc/network/if-up.d/upif" > /dev/null << EOFBOOT
#!/bin/bash
DISPLAY=":0"
if [[ "$IFACE" = "eth0" || "$IFACE" = "wlan0" ]]; then
echo "$(date) $IFACE" >> /var/log/upif
firefox-esr &
fi
EOFBOOT
sudo chmod +x "/etc/network/if-up.d/upif"
I am getting the date and the interface name in my log file, which means the script runs, but firefox-esr
doesn't start.
What I've tried:
- adding
DISPLAY=":0"
grep -inR "firefox" /var/log
- using full path to executable, i.e.
/usr/bin/firefox-esr
- using
sudo firefox-esr &
- removing the trailing
&
Nothing helped. However, if I put IFACE="eth0"
below the shebang and then run sudo /etc/network/if-up.d/upif
manually, that exact script you see above does the job and starts firefox.
I am not sure what's the problem there. Spent few hours on it already. Please help!
This is 2018-06-27-raspbian-stretch-lite
running Debian 9.4.
P.S. Also I initially had logic checking whether Firefox already runs before attempting to start it, but once I realised Firefox isn't launched at all, I removed it
UPDATE Found a similar problem: Start a GUI in NetworkManager if-up.d script
debian raspberry-pi raspbian firefox gui
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I need to start firefox-esr
once the network is available.
Here's what I've got:
sudo tee "/etc/network/if-up.d/upif" > /dev/null << EOFBOOT
#!/bin/bash
DISPLAY=":0"
if [[ "$IFACE" = "eth0" || "$IFACE" = "wlan0" ]]; then
echo "$(date) $IFACE" >> /var/log/upif
firefox-esr &
fi
EOFBOOT
sudo chmod +x "/etc/network/if-up.d/upif"
I am getting the date and the interface name in my log file, which means the script runs, but firefox-esr
doesn't start.
What I've tried:
- adding
DISPLAY=":0"
grep -inR "firefox" /var/log
- using full path to executable, i.e.
/usr/bin/firefox-esr
- using
sudo firefox-esr &
- removing the trailing
&
Nothing helped. However, if I put IFACE="eth0"
below the shebang and then run sudo /etc/network/if-up.d/upif
manually, that exact script you see above does the job and starts firefox.
I am not sure what's the problem there. Spent few hours on it already. Please help!
This is 2018-06-27-raspbian-stretch-lite
running Debian 9.4.
P.S. Also I initially had logic checking whether Firefox already runs before attempting to start it, but once I realised Firefox isn't launched at all, I removed it
UPDATE Found a similar problem: Start a GUI in NetworkManager if-up.d script
debian raspberry-pi raspbian firefox gui
I need to start firefox-esr
once the network is available.
Here's what I've got:
sudo tee "/etc/network/if-up.d/upif" > /dev/null << EOFBOOT
#!/bin/bash
DISPLAY=":0"
if [[ "$IFACE" = "eth0" || "$IFACE" = "wlan0" ]]; then
echo "$(date) $IFACE" >> /var/log/upif
firefox-esr &
fi
EOFBOOT
sudo chmod +x "/etc/network/if-up.d/upif"
I am getting the date and the interface name in my log file, which means the script runs, but firefox-esr
doesn't start.
What I've tried:
- adding
DISPLAY=":0"
grep -inR "firefox" /var/log
- using full path to executable, i.e.
/usr/bin/firefox-esr
- using
sudo firefox-esr &
- removing the trailing
&
Nothing helped. However, if I put IFACE="eth0"
below the shebang and then run sudo /etc/network/if-up.d/upif
manually, that exact script you see above does the job and starts firefox.
I am not sure what's the problem there. Spent few hours on it already. Please help!
This is 2018-06-27-raspbian-stretch-lite
running Debian 9.4.
P.S. Also I initially had logic checking whether Firefox already runs before attempting to start it, but once I realised Firefox isn't launched at all, I removed it
UPDATE Found a similar problem: Start a GUI in NetworkManager if-up.d script
debian raspberry-pi raspbian firefox gui
asked Jul 27 at 7:11
aexl
1112
1112
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
The network event scripts run as the root user, but your desktop environment probably (hopefully) isn't.
This seems like a problematic approach in general. A few things are missing:
- Firefox should run as your logged in user, not root.
- Firefox needs to be able to authenticate to the X server to connect to it (see
~/.Xauthority
andman xauth
). - Firefox's environment needs to be set up to work properly in the desktop session (
HOME
,XDG_RUNTIME_DIR
etc.)
I would suggest trying a different approach, e.g. having the network script communicate network status (via a pipe / temporary file / DBus) to something already running in the user session (launched e.g. from ~/.xinitrc
), which then launches GUI apps as needed.
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
add a comment |Â
up vote
0
down vote
Thanks to Fadabi Nawi, here's what the answer was:
su pi -c "DISPLAY=:0.0 /usr/bin/firefox-esr &"
Key points:
- su to the actual user you normally use (
pi
in my case) - pass the display number right there (TODO: find out the actual display number instead of assuming it's
:0
)
important use the full path to Firefox executable, instead offirefox-esr
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
The network event scripts run as the root user, but your desktop environment probably (hopefully) isn't.
This seems like a problematic approach in general. A few things are missing:
- Firefox should run as your logged in user, not root.
- Firefox needs to be able to authenticate to the X server to connect to it (see
~/.Xauthority
andman xauth
). - Firefox's environment needs to be set up to work properly in the desktop session (
HOME
,XDG_RUNTIME_DIR
etc.)
I would suggest trying a different approach, e.g. having the network script communicate network status (via a pipe / temporary file / DBus) to something already running in the user session (launched e.g. from ~/.xinitrc
), which then launches GUI apps as needed.
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
add a comment |Â
up vote
2
down vote
The network event scripts run as the root user, but your desktop environment probably (hopefully) isn't.
This seems like a problematic approach in general. A few things are missing:
- Firefox should run as your logged in user, not root.
- Firefox needs to be able to authenticate to the X server to connect to it (see
~/.Xauthority
andman xauth
). - Firefox's environment needs to be set up to work properly in the desktop session (
HOME
,XDG_RUNTIME_DIR
etc.)
I would suggest trying a different approach, e.g. having the network script communicate network status (via a pipe / temporary file / DBus) to something already running in the user session (launched e.g. from ~/.xinitrc
), which then launches GUI apps as needed.
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The network event scripts run as the root user, but your desktop environment probably (hopefully) isn't.
This seems like a problematic approach in general. A few things are missing:
- Firefox should run as your logged in user, not root.
- Firefox needs to be able to authenticate to the X server to connect to it (see
~/.Xauthority
andman xauth
). - Firefox's environment needs to be set up to work properly in the desktop session (
HOME
,XDG_RUNTIME_DIR
etc.)
I would suggest trying a different approach, e.g. having the network script communicate network status (via a pipe / temporary file / DBus) to something already running in the user session (launched e.g. from ~/.xinitrc
), which then launches GUI apps as needed.
The network event scripts run as the root user, but your desktop environment probably (hopefully) isn't.
This seems like a problematic approach in general. A few things are missing:
- Firefox should run as your logged in user, not root.
- Firefox needs to be able to authenticate to the X server to connect to it (see
~/.Xauthority
andman xauth
). - Firefox's environment needs to be set up to work properly in the desktop session (
HOME
,XDG_RUNTIME_DIR
etc.)
I would suggest trying a different approach, e.g. having the network script communicate network status (via a pipe / temporary file / DBus) to something already running in the user session (launched e.g. from ~/.xinitrc
), which then launches GUI apps as needed.
answered Jul 27 at 7:30
Vladimir Panteleev
719416
719416
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
add a comment |Â
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
Thank you for your answer. I've managed to make it the initial approach work - turned out to be easier than I thought it would be. I've shared what helped and will mark that as an answer. Upvoted your answer to appreciate the effort and a quick response. Thanks again!
â aexl
Jul 27 at 7:38
add a comment |Â
up vote
0
down vote
Thanks to Fadabi Nawi, here's what the answer was:
su pi -c "DISPLAY=:0.0 /usr/bin/firefox-esr &"
Key points:
- su to the actual user you normally use (
pi
in my case) - pass the display number right there (TODO: find out the actual display number instead of assuming it's
:0
)
important use the full path to Firefox executable, instead offirefox-esr
add a comment |Â
up vote
0
down vote
Thanks to Fadabi Nawi, here's what the answer was:
su pi -c "DISPLAY=:0.0 /usr/bin/firefox-esr &"
Key points:
- su to the actual user you normally use (
pi
in my case) - pass the display number right there (TODO: find out the actual display number instead of assuming it's
:0
)
important use the full path to Firefox executable, instead offirefox-esr
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Thanks to Fadabi Nawi, here's what the answer was:
su pi -c "DISPLAY=:0.0 /usr/bin/firefox-esr &"
Key points:
- su to the actual user you normally use (
pi
in my case) - pass the display number right there (TODO: find out the actual display number instead of assuming it's
:0
)
important use the full path to Firefox executable, instead offirefox-esr
Thanks to Fadabi Nawi, here's what the answer was:
su pi -c "DISPLAY=:0.0 /usr/bin/firefox-esr &"
Key points:
- su to the actual user you normally use (
pi
in my case) - pass the display number right there (TODO: find out the actual display number instead of assuming it's
:0
)
important use the full path to Firefox executable, instead offirefox-esr
answered Jul 27 at 7:32
aexl
1112
1112
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f458767%2fan-etc-network-if-up-d-script-runs-but-doesnt-launch-gui-apps-e-g-firefox%23new-answer', 'question_page');
);
Post as a guest
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
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
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