#!/bin/bash
INTERFACE=$(/usr/libexec/PlistBuddy -c "Print :NetworkInterFace" /Users/Shared/MenubarTools/WiFiHelper/WiFiInfo.plist 2>/dev/null)

NetworkInterface=$(osascript <<EOF
display dialog "输入Wi-Fi网络接口名称，例如：en0" buttons {"确定", "取消"} default button 1 default answer "${INTERFACE}"
set returnRecord to the result --获取返回的record类型的值
set NetworkInterface to get the text returned of returnRecord -- 获取输入的文本
if NetworkInterface = "" then
	return ""
else
	if button returned of returnRecord = "确定" then
		return NetworkInterface
	else
		return ""
	end if
end if
EOF
)	



if [ "X$NetworkInterface" == "X" ]; then
	echo exit
	exit 0
fi
	
/usr/libexec/PlistBuddy -c "Set :NetworkInterFace ${NetworkInterface}" /Users/Shared/MenubarTools/WiFiHelper/WiFiInfo.plist 
 if [ $? -ne 0 ]; then
    exit 1
 else
     exit 0
 fi