#!/usr/bin/env bash
# thanks https://wiki.archlinux.org/index.php/Wicd#Change_MAC_using_macchanger

connection_type="$1"
wireless="wlan0"
wired="eth0"

if [[ "${connection_type}" == "wireless" ]]; then
  iface="$wireless"
elif [[ "${connection_type}" == "wired" ]]; then
  iface="$wired"
fi

ip link set $iface down
macchanger -A $iface
ip link set $iface up