Run script after connected to wifi
Hi,
is there a way to run a script after I connected or disconnected to/from a (wifi) network? I want to automate the VPN connection after I connected to certain networks.
Thanks!
We have moved to a new Sailfish OS Forum. Please start new discussions there.
Hi,
is there a way to run a script after I connected or disconnected to/from a (wifi) network? I want to automate the VPN connection after I connected to certain networks.
Thanks!
Yep.. You can run script like this:
#!/bin/bash
connection=$(/usr/lib/qt5/bin/qdbus --system net.connman /net/connman/technology/wifi net.connman.Technology.GetProperties|grep Conn|awk '{print $2}')
if [[ "$connection" == "true" ]]; then
echo "Connected to WIFI" #Do what your need.
else
echo "NOT connected !" #Do what your need.
fi
The above script only queries the current state. You could use it to poll the connection state, but that would not be ideal. Instead I suggest you listen for changes to the Connected property of the /net/connman/technology/wifi DBus path.
Aaron McCarthy ( 2014-07-03 06:53:30 +0200 )editThis thread is public, all members of Together.Jolla.Com can read this page.
Asked: 2014-06-27 00:03:05 +0200
Seen: 1,766 times
Last updated: Jun 27 '14
Advanced network config [answered]
Why saved WLAN networks disappear and re-appear [released]
3G network status icon [answered]
Bug: mobile network [answered]
Airplane mode enabled, still ask "select internet connection".
Network monitor & personal firewall
Cellular network stays online although it is disabled (while wlan enabled) [answered]