Question: I recently restarted after an update on 15.10, and now the keyboard on my laptop (Lenovo Thinkpad Yoga) doesn't work. I can't even ctrl-alt-[N] to get to a virtual terminal, nor does a USB keyboard work. The keyboard *does* work in BIOS setup and GRUB mode, but that's it. Also, the touchscreen stopped working at the same time. I had also changed a line in a xorg.conf.d file, affecting the synaptics driver prior to this, but I can't work out why this would kill the keyboard and touchscreen.

Answer: 
Run

> 
> dbus-monitor --system "type='signal',interface='org.freedesktop.NetworkManager'"
> 
> 
> 

Then change your wifi connection. You will get the signal that property changed. It returns a "PrimaryConnection" that is activated.

You can then query the activated connection and see if it matches the connection you are interested in.

For example:

> 
> qdbus --system --literal org.freedesktop.NetworkManager
> /org/freedesktop/NetworkManager/ActiveConnection/Whatever
> org.freedesktop.DBus.Properties.GetAll
> org.freedesktop.NetworkManager.Connection.Active
> 
> 
> qdbus --system --literal org.freedesktop.NetworkManager
> /org/freedesktop/NetworkManager/AccessPoint/Whatever org.freedesktop.DBus.Properties.Get
> org.freedesktop.NetworkManager.AccessPoint.Ssid
> 
> 
> 

(probably just simpler to run iwgetid -r after you detect the property change)
While it's certainly possible to use `dbus` , personally I'd go with simple bash while loop + awk

```
while [ "$(iwconfig 2> /dev/null |  awk '/Access Point/ && /XX:YY:ZZ:11:22:33/ {print "true" }')" != "true" ]; do : ; sleep 0.25 ;done ; echo DONE

```

What is happening there ? While loop keeps running, testing output of `iwconfig` filtered out with `awk`. So far as the `awk` doesn't find the mac address of the access that you want to connect to, loop continues running. As soon as `awk` sees that you've associated with that particular AP , the test condition `[ "String1" != "String2" ]` becomes false, loop breaks , and goes on to the `echo DONE` command. Of course , `echo DONE` is what can be replaced with the program that you want to run.

This command can be ran manually or placed into a script, and the script added to the Startup Application list.

Simple, straightforward, and does the job. Like I said in the beginning, it is possible to use dbus , but is not as simple.