Adium
Dock Icons Emoticons Contact List Styles Message Styles Sound Sets AppleScripts Status Icons Service Icons Menu Bar Icons Plugins Miscellaneous All
IPStatus

IPStatus

Submitted By Ankit (ankit.modi)

Description

An Applescript to set Adium Status according to IP Address of your computer.

The plugin is activated when status message contains a string %_ipstatus{}

Some_Status_Options is an array containing Statuses.
eg. %_ipstatus{@Work,10.*, Available,192.168.*}

This means whenever I am connected to network with ip 10.x.x.x ( wired or wireless ) it sets status "@Work"
else for ip 192.168.x.x it sets status "Available".

If wired ip address is present it gives it a preference over a wireless ip address. Hence for above example if wired has ip 10.x.x.x and wireless has ip 192.168.x.x then status would be "@Work"


TODO:
Add support to change status type. Not added due to a bug in AppleScript interface.

Credits:
Thanks Craig Younkins ( http://home.comcast.net/~cyounkins/adium/ ) for his help page.

Changes

v1.0
--- First cut of the script
V1.1
--- Added support for arguments for defining the location

Comments

You can reply to individual comments by clicking the "Reply" link next to each.

# by zacw on 01/21/09 at 13:43:10

The only suggest I have is to make the locational changes part of the argument.

i.e., %_ipLocation{192.168.*, Home, 10.*, Work}

That way the "casual user" doesn't have to edit the Xtra bundle.

# by ankit.modi on 01/21/09 at 15:34:05

Sure. I'll try to include that feature.

Thank you for your comment.

# by Xjs on 02/01/09 at 06:16:14

Does it have IPv6 support?

# by ankit.modi on 02/01/09 at 15:26:58

I havent thought about IPv6. But I dont think there is any reason why it should not work in IPv6. Its a simple pattern match. Let me know if you encounter problems in IPv6.

# by Xjs on 02/01/09 at 15:34:17

You should check if the IP string contains colons (:) - which makes it most probable that they are IPv6 - and if yes, check the machine's IPv6 instead of the IPv4. You check by grepping the en0 and en1 interfaces - which won't always work for IPv6 (as tunnel mechanisms use the stf or tun interfaces). You should rather grep the whole ifconfig output for a string like:

inet6 2a01:198:300::1 prefixlen 48

- where you get the IPv6 right away. Also, if the computer has several IP(v4 or v6)s assigned (which might actually happen with the whole lot of IPv6 addresses around), you'll get all of them - and should also check all of them (I'm not too good in Perl, but I think your script already does that, huh?).

# by ankit.modi on 02/01/09 at 15:41:57

Great! I havent tried IPv6 anytime so not aware how it is represented.

I'll add your suggestions.

Thanks!

# by marianobntz on 03/10/09 at 16:18:35

Great tool, I also want status type change, probably a default value would be useful too, when no ip addresses match.

Thanks, I've been looking for this for a long time :)

MAriano

# by ankit.modi on 03/10/09 at 16:36:21

Due to a bug in Adium applescript interface, I am not able to change status type. I am very curious in doing so as soon as it is available.

If you dont specify a status and ip then the status would be set to
e.g. %_ipstatus{@Work,10.*}
For this it will set status to @Work on a 10.* ip and status text on any other ip address.

Is that what u intended by default ?

# by marianobntz on 03/10/09 at 16:43:17

I would like that instead of a blank message, I can define a custom one, like "I don't know where I am.." :)

Another thing, does your status texts support putting other script plugins, like %_myip or something like that?

Thanks,
PS: Any ETA when adium can fix the applescript so we can set the status type?

# by ankit.modi on 03/10/09 at 16:50:36

Hmm... I can incorporate the default. I'll update the package when I do it.

I am not sure about script plugins. I havent tried it. Chances are less that it will work.

Regarding the ETA on fix I am not sure. I currently cannot find the bug. I'll see if it is fixed and if so I'll add up the changes :)

# by mrvisual on 05/12/09 at 12:58:00

Would be nice to select the message according to the current connected wlan -- feelin' bored :-) ??

# by ankit.modi on 05/21/09 at 16:28:19

Need to add support for "," in message...

# by vlbrown on 10/06/09 at 18:30:27

I don't understand why this only works for me at home. Here's my status messsage:
%_ipstatus{in the office, 10.72.*, working from home, 192.168.*}
Status for 192.168.* works (shows in my status message). Status for 10.72.* does not work.

# by vlbrown on 10/12/09 at 20:15:23

Hmmm... It's working now and all I changed was spaces. Apparently, it does NOT like a space between the , and the IP address
%_ipstatus{in the office, 10.72.*, working from home, 192.168.*}
fails
%_ipstatus{in the office,10.72.*,working from home,192.168.*}
works

# by msabramo on 11/03/10 at 01:57:46

I had a few problems with this - my Snow Leopard system has an extra line with IPv6 info that I don't think the Perl script was expecting so I had to modify the Perl script to look for 3 lines of context instead of 2.

marca@ladyproud-lm:~/Library/Application Support/Adium 2.0/Scripts/IPStatus.AdiumScripts/Contents/Resources$ diff -u /tmp/IPStatus.AdiumScripts/Contents/Resources/getStatus.pl getStatus.pl
--- /tmp/IPStatus.AdiumScripts/Contents/Resources/getStatus.pl 2009-01-29 21:01:08.000000000 -0800
+++ getStatus.pl 2010-11-02 15:53:22.000000000 -0700
@@ -6,13 +6,13 @@
#print $inputText."n";

# Get Ethernet IP Address
-my $ipAddress= `ifconfig | egrep -C 2 'en0:' | grep 'broadcast' | awk '{print $2}'`;
+my $ipAddress= `ifconfig | egrep --after=3 'en0:' | grep 'broadcast' | awk '{print $2}'`;
chomp $ipAddress;

# if Ethernet ipaddress is not present get wireless ipAddress
if ( length($ipAddress) < 1 )
{
- $ipAddress = `ifconfig | egrep -C 2 'en1:' | grep 'broadcast' | awk '{print $2}'`;
+ $ipAddress = `ifconfig | egrep --after=3 'en1:' | grep 'broadcast' | awk '{print $2}'`;
chomp $ipAddress; home
}

The other thing that tripped me up is that the default status string given ("%_ipstatus{@Work,10.*, Available,192.168.*}") could be improved. I was at home and my IP address happened to be 192.168.1.101 -- this actually matches the "10.*" regex and so therefore it thinks I'm at work. I suggest adding caret symbols to the regexes so the matches are a little tighter -- e.g.:

%_ipstatus{@Work,^10.*, @Home,^192.168.*}

Post a New Comment

You must be logged in to post comments.

Install | Download
3.94kb (664 downloads)

12345
4.00 / 3 votes
Current Version: 1.1
Last Updated: 01/30/09