#!/bin/bash

# check if gui is runnning, if so bring it to front and do nothing more
if pgrep wicd-client; then
   xdotool search --name "Wicd Network Manager" windowactivate
   exit
fi

CONF=/etc/wicd/manager-settings.conf

# remove previously configured settings so wicd can gather fresh ones
# then run wicd gtk gui application
service wicd stop
sed -i -r "s/^wireless_interface.*=.*//" $CONF
sed -i -r "s/^wired_interface.*=.*//" $CONF
sed -i -r "s/^wpa_driver.*=.*//" $CONF
service wicd start

# start gui client
wicd-client --no-tray
