Answer the question
In order to leave comments, you need to log in
Programmatically detect when Network Manager connects to network
I would like to add a browser to startup, but so that it does not open if I'm not at home (no wi-fi connection). As far as I know, nm provides similar functionality. For example, pidgin does not try to connect when there is no connection in nm, but simply waits for a connection. I would like to write a script that waits a minute for a connection and launches a browser if a connection is made. Where to dig?
OS - Ubuntu 11.04.
Answer the question
In order to leave comments, you need to log in
Dig in the direction of DBus and, accordingly, the NetworkManager'a interface for it.
As an option, add a script to /etc/NetworkManager/dispatcher.d/
For example,
But I didn’t fully understand the bugs with environment variables ...
#!/bin/bash
# первый параметр скрипта - интерфейс
IF=$1
# второй параметр скрипта - состояние (up/down/pre-up/post-down)
STATUS=$2
# Если интерфейс тот, который мне нужен и он поднялся, то проверяем дальше
if [ "$IF" = "wlan0" ] && [ "$STATUS" = "up" ];
then
# Если мы подключились к своей точке (00:1E:58:FF:AF:FA)
iwconfig "wlan0" | grep "00:1E:58:FF:AF:FA" > /dev/null
if [ $? == "0" ];
then
# То выполняем запуск гуглохрома от имени юзера user
env DISPLAY=:0.0 su user -l -c google-chrome &
exit $?
fi
fi
My advice to you: dig towards Qt. And everything will be clear there.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question