Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

frenetic

macrumors regular
Original poster
Feb 11, 2004
228
27
Amsterdam
Dear all,

I have a question for which I have been googling a lot but I don't seem to find the correct answer. I am looking to automate a process in which I link an iTunes eq setting to the MAC address of the wireless network I am connected to. Concretely, I move my laptop a lot between several places. In Amsterdam the airport express is connected to a hifi installation that does not have an equalizer setting. What I would like is to create an apple script that activates the Amsterdam equalizer setting once I am connected to that network, and that deactivates that same setting once I am connected to another one. Through my googling activities I have tried to create such a script but I don't get it to work and I don't understand enough of applescript to correct it:

tell application "iTunes"
if airport MAC address is "00:23:6c:7f:31:f4" then
set the current EQ preset to EQ preset "amsterdam"
end if
if airport MAC address is not "00:23:6c:7f:31:f4" then
set the current EQ preset to EQ preset "Flat"
end if
end tell

Does anybody know what I am doing wrong? Thanks in advance...

Frenetic
 
Try this (replace 00:11:22:33:44:55 (in bold) with your MAC address):

Code:
try
	set macAddressText to text of (do shell script "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | grep BSSID")
	
	set macAddress to (word 2) of macAddressText
	set macAddress to macAddress & ":" & (word 3) of macAddressText
	set macAddress to macAddress & ":" & (word 4) of macAddressText
	set macAddress to macAddress & ":" & (word 5) of macAddressText
	set macAddress to macAddress & ":" & (word 6) of macAddressText
	set macAddress to macAddress & ":" & (word 7) of macAddressText
	if macAddress is "[B]00:11:22:33:44:55[/B]" then
		tell application "iTunes"
			set the current EQ preset to EQ preset "amsterdam"
		end tell
	else
		tell application "iTunes"
			set the current EQ preset to EQ preset "Flat"
		end tell
	end if
on error -- This is for if you are not even connected to a network.
	display alert "You are not connected to a wireless network ! 
Setting Flat EQ."
	tell application "iTunes"
		set the current EQ preset to EQ preset "Flat"
	end tell
end try

Probably could be cleaner, but it's still functional.
 
Wow, I am not at home so can't check it out but it looks like its functioning, since running the script changed it back to "flat"! Sircharlo, you are great! I cannot thank you enough for this, and will be studying what it does precisely.
 
Ahum, I was too enthusiastic. Just got home and I encountered a problem - when home it does not switch to the "amsterdam" eq. I don't fully understand the shell script you invoke, but it might have to do with the fact that my house modem + router is not an apple express or base station, but a zyxel (with one airport express attached for streaming music). Could that be the reason?
 
I solved it - for a reason that I don't understand the MAC address of the wireless router is reported to the MAC OS as 0:23:f8:21:d5:54 (with the first 0 missing). I noticed that by holding alt and clicking the airport symbol in the menu bar. Once I changed that the script works. Odd.

Now next question: the script only works if I run it myself. Is there a way to automate the process? That I make it a log-in item and that every time I change network location it performs the check?
 
Try saving your application as an Application Bundle in Script Editor (NOT run only).
And try moving your app bundle to your /Applications/ folder.
Try going in System Preferences, Accounts, Your Account, Login Items, and try adding your script to that list.

Works ?
 
Hmmm... it doesn't work automatically. I have saved it as an application (not script bundle), put it in my log-in items, but it does not change the EQ settings. When I run the script manually, though, it works perfectly. Maybe there should be a command in there that registers every change in the wireless network, or something to make it check every 20 secs? Anyway, this is already much better than having to manually check and uncheck the equalizer settings, so I will not abuse of your time anymore. Thanks again!
 
I have two Airport Expresses running at my house. Both are connected to different types of speakers. Neither speaker set has its own equalizer, and both require a different EQ setting to sound just right.

Any ideas on a script that will help with this?
 
Please elaborate...
Are you playing simultaneously with both airports express, or only one at a time?
I don't think there's a way to set the eq for each airport express seperately... So if you're using both simultaneously, you'd have to find some middle ground eq setting in itunes, or your app of choice.

If you only use one set of wireless speakers at a time, a script could help you there, by setting an eq depending on which speakers are connected...

So, which is it?
 
I rarely play them both at the same time. So a script that changes the EQ based on which express it is playing to would be perfect. Maybe if they are both playing it could default to a standard eq?

I know nothing about writing scripts, so your help would be greatly appreciated!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.