Global scripts
Global scripts are run for every connection, both wired and wireless.
Simply place an executable script (actually, any executable file) in one of the subfolders in /etc/wicd/scripts.
The scripts are passed three parameters: whether the connection is wired or wireless, the ESSID (for wired networks this is just "wired" again) and the BSSID (wirelss) or profile name (wired) of the network.
For example, your script foo.sh might be called as
foo.sh wireless homewrls 00:28:B4:A3:34:34
or
foo.sh wired wired office
You can use the following as a base for your script:
#!/bin/bash
script="$(basename "$0")"
script_name="${script/.sh/}"
echo "Running ${script}" >"/var/log/wicd/${script_name}.log"
exec 2>>"/var/log/wicd/${script_name}.log"
exec 1>&2
connection_type="$1"
echo "Connection type: ${connection_type}"
if [ "${connection_type}" == "wired" ]; then
profile="$3"
echo "Profile: ${profile}"
elif [ "${connection_type}" == "wireless" ]; then
essid="$2"
bssid="$3"
echo "ESSID: ${essid}"
echo "BSSID: ${bssid}"
else
echo "Unknown connection type: ${connection_type}" >&2
exit
fiJust add the code you want to run to the end, using the script variables $connection_type, $profile, $essid and $bssid.
Per-connection scripts
You can also assign scripts per-connection. For each connection, you can run up to one script just before connecting (pre-connect), one just after (post-connect), one just before disconnecting (pre-disconnect) and one just after disconnecting (post-disconnect).
You can do this by setting the beforescript, afterscript, predisconnectscript and postdisconnectscript entries in /etc/wicd/wireless-settings.conf and /etc/wicd/wired-settings.conf. You can also try to use wicd-gtk for this: in the network's settings page simply press the "Scripts" button.
On execution the are passed two arguments: BSSID and ESSID. Note that these are in reverse order to global scripts. If the network is wired the arguments will both simply be "wired". To see if wicd executes scripts you can run wicd on the foreground, for example by running 'wicd -f -o -e -a'. This requires root permissions.
