How can I automatically keep track of in-office hours when I connect to my office Wi-Fi?
Solution 1:
ControlPlane might be something you can use to accomplish this:
ControlPlane determines where you are or what you are doing based on a number of available evidence sources and then automatically reconfigures your Mac based on your preferences. Evidence sources can include your current location, visible WiFi networks, attached USB devices, running applications and more. You can even write your own evidence sources using shell scripts!
In a nutshell, you can give ControlPlane an "evidence source", such as
- WiFi, either networks within range or based on the network you are currently connected to
Then perform a set of actions when entering (or leaving) a particular context, such as
- Open any file, including starting Applications
- Run a script, such as AppleScript or shell script
My thinking here is that if ControlPlane knows what your office wifi is called, you can create rules so that when you connect to it you start an application or shell script to start logging your hours. Then, when you disconnect, you stop the application or run another shell script to stop logging your hours.
I realise this might not be the "silver bullet" solution you were looking for, but it might be worth a try. You'll still have to find some kind of timer app/script, but thats probably the easier part of the problem :)
Solution 2:
You can use the command networksetup -getairportnetwork <device>
to get the name of your currently-connected wireless network (where is the device ID of your airport--probably en1).
From there, you can use launchd to schedule a script to run every 5 minutes or so which will get the name of the wireless network you're connected to and log when you first connect to your work wi-fi.
Depending on what you want, you could then use the same script to log another entry when it notices you're no longer connected to your work wi-fi, or to post some sort of notification (perhaps using growl) on specific intervals. Something along the lines of "I've been at work for 9 hours--time to go home".
Or you could use the start/end times in a running log and write another script to parse it and create some sort of report.
I've got bits and pieces of these types of scripts lying around, if time at work allows, I'll add something here.
man launchd
is quite useful.