CurrentKey Stats lets you fully customize your environment by supporting advanced AppleScript functionality. This means you can write a script that tells CurrentKey to go to a specific Room or even to return specific stats. CurrentKey can also notify your own custom AppleScript every time you switch between Rooms. This enables you to trigger Room-specific functionality outside of the app. Let your imagination run wild with all the possibilities: turn on cool LED lights when you enter your gaming Room? You can write a script for that! Bring your favorite programming app to the foreground when you enter your work Room? Write a script for that! Assign a specific radio station to play when you enter a Room? Pause a timer when you leave a specific Room? It can be done! The possibilities are infinite, and here are a few articles exploring some of those ideas.
CurrentKey responds to 14 AppleScript commands. One of them is for triggering Script Images. But to use any of the other commands, you have to enable AppleScript communication in the Background Services panel via Preferences.
These commands mean you can ask CurrentKey, programmatically, to do the following things:
– Show a specific image in the app’s menubar icon for a specific amount of time.
– Get a summary of the day’s stats so far.
– Go to a specific, assigned Room (the same as clicking a “Go to Room” option from the popover’s dropdown).
– Get all assigned Room names and the active Room name.
– Get total time spent, today or yesterday, across all apps
– Get total time spent, today or yesterday, across a specific Room
– Get total time spent, today or yesterday, in a specific app
– Get total time spent, today or yesterday, in a specific app in a specific Room
– Get the name of the active app
– Get total time spent, today or yesterday, in a specific app
– Get a list of all apps and their bundle names (the latter is needed for other app-specific commands)
There are also Room change alerts, which offer AppleScript support in the opposite direction (your script will get called with the new Room name). Go here for more on Room change alerts as well as many ideas on how to make use of all this power!
Below I will share what the actual AppleScript support for the above commands look like. But first, let me show you what the description of the commands are:
For any of these commands to actually work, you must first enable the feature in the Background Services panel:
In practice, here’s a video of what these commands look like:
Want to do something more complex and feeling constrained by AppleScript? Here is a tutorial on how to pass these variables on to a local Python script! With Python, you can more easily loop over data, set variables, etc – you know, full coding stuff!
If you want to query about time spent in fullscreen, use “_fullscreen_” as the RoomName parameter. Similarly, if the getactiveroom command is sent while your fullscreen, the app will respond “_fullscreen_”.
Here are slightly simpler one-liner examples of those commands:
tell application “CurrentKey Stats” to getactiveroom
tell application “CurrentKey Stats” to getassignedrooms
tell application “CurrentKey Stats” to gotoroom called “theNameOfAssignedRoom”
tell application “CurrentKey Stats” to appandbundlenames
tell application “CurrentKey Stats” to totaltime_today
tell application “CurrentKey Stats” to timeforapp_today withbundlename “com.apple.dt.Xcode”
tell application “CurrentKey Stats” to timeforappforroom_today withbundlename “com.apple.dt.Xcode” withroomname “coding”
tell application “CurrentKey Stats” to totaltime_yesterday
tell application “CurrentKey Stats” to timeforapp_yesterday withbundlename “com.apple.dt.Xcode”
tell application “CurrentKey Stats” to timeforappforroom_yesterday withbundlename “com.apple.dt.Xcode” withroomname “coding”
tell application “CurrentKey Stats” to timeforroom_today withroomname “coding”
tell application “CurrentKey Stats” to timeforroom_yesterday withroomname “coding”
tell application “CurrentKey Stats” to getactiveappname
tell application “CurrentKey Stats” to getactiveappbundlename