Categories
AppleScript CurrentKey Stats

Brainstorming cool ways to use CurrentKey via its AppleScript support

My hope is that CurrentKey helps you use your Mac more productively and that you can have some fun along the way. Because I have added extensive AppleScript support, there are endless possibilities to spice up your Mac experience.

A simple AppleScript that will do something custom upon entering a specific Room (Space) or activating an app.

What could I do with this power?

Just brainstorming off the top of my head, here are some ideas for theme-based Room customization, as well as scripts or individual actions that could make sense to trigger (upon entering/leaving Rooms).

On alerts when you enter a Room: automatically bring a specific app to the front? ✅ take a screenshot? ✅ mute the volume? ✅ toggle macOS dark mode? ✅ activate LED desk lights? ✅ trigger and IFTTT routine? ✅ selectively start/stop a timer based on what Room you are in or App is active? ✅ You can even pass parameters along to a Python script. Here's a tutorial.

You can also pair Room alerts with CurrentKey's support for 14 AppleScript commands for even more nuanced outcomes.

Ideas for unique Room themes:
  • Have a "language learning" Room, and assign custom internet radio stations for them with Broadcasts, so it would start playing a Spanish station when you go into your Spanish Room! 🗣️ (click the tutorial ^ 😁)
  • Show a banner notification with the name of each Space/Room you move into. (Here's the tutorial)
  • Have a "Weather" Space and refresh several weather radar maps in Safari, Chrome, or Brave, immediately upon entering. ☀️
  • Give each of your Spaces a picture-in-picture video intro with Helium 3. 🎬 ➡️ 🎥
  • Have a "distraction free" space that mutes volume, activates dark mode, hides dock, and turns off WiFi. 🤫 It could return settings to normal when leaving.
  • Have a "Communication HQ" Room that will automatically sync your Mail app to check for latest email upon entering… and sync your Evernote notebooks too. 📬 🔄
  • Assign each room in your house to a different Room in CurrentKey, so that when you walk into your kitchen, you're taken to the Space with your recipes, kitchen timers, and more! This is possible with EventScripts and iBeacons. 🏠

A list of specific actions you could selectively combine to create really cool scripts:

  • Create a smart Pomodoro timer that stops and starts when you're in specific apps (or Spaces). This one already has AppleScript support 🍅 ⏱
  • Refresh a specific webpage in Chrome, Safari, etc (they all support automation), either when that browser becomes active (with App change notifications), or when you enter a room.
  • Pause/resume a screen sharing application
  • Bring a specific app to the front
  • Activate smart home things, like LED lights, sound systems, etc
  • Hook it up to IFTTT to run a Room-specific workflow
  • Refresh Mail's Inbox for new messages with its "check for new mail" command
  • Have the name of the current Room (Space) be read aloud
  • Take a screenshot
  • Run a local Python script
  • Start/pause an Amphetamine session, which actually has terrific AppleScript support.
  • Start a presentation
  • Play a specific set of Spotify tracks
  • Crank up or mute your Mac's volume
  • Pause/unpause your media player
  • Automatically tell a Slack channel you've left or entered a Room.
  • Add a note, maybe with additional context via CurrentKey's stat-fetching commands, in a powerful program like Agenda, which puts such notes on a timeline.
  • Start a Photos slideshow.
  • You can use CurrentKey's stats-fetching commands, to add more nuance, like only activating certain scripts if certain time-spent threshold had/hadn't been met. You can even tell a CurrentKey to go to a certain Room programmatically. So you could move between your Spaces with a remote control (or a phone) 🕹️!
  • Have an app you'd like me to build into a Rooms workflow? Let me know on Twitter!

How is this enabled and set up?

First, head to the new Background Services panel, found via Preferences. Next, click the Open button that is next to the "It will look for a user-provided "ck.scpt" in this folder:" label. This will open your Finder to the directory that you will place your custom AppleScript.

In the example above, the AppleScript will get called with a "roomName" parameter. It checks to see if the Room's name is "coding", and if it is, it brings Xcode to the front through AppleScript's "activate" command. If you move into a fullscreen app, the parameter will read "_fullscreen_".

This concept is simple and powerful, enabling 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 coding Room? Write a script for that! Pause a timer when you leave a specific Room? It can be done! The possibilities are infinite! There's a tutorial that includes a video here.

Categories
AppleScript CurrentKey Stats

How to give each of your Mac’s Spaces a custom sound 👂🏻

We all know about the MacOS feature called Spaces, and many of us love splitting our projects, work, and hobbies across our virtual desktops.

What if you could not just assign a name to each Space but also assign a custom Internet radio station to each one too? As you move between them, immersive sound would automatically start playing. Thanks to AppleScript support in Broadcasts (by Steve Troughton-Smith), this is possible! (Skip ahead to the video below to see it in action.) Here's a common use case:

Say you're studying a second language and arrange your learning materials in a Space you call "Spanish". I'll share a script below that…. When you move into your "Spanish" Space, will tell Broadcasts to play a radio station by its name, in this case "Cadena SER España". Let's say you want another Space for all things related to your hometown sports team. In my case, this would be the Texas Longhorns. So when I move into "Sports", we'll play from the "104.9 The Horn Austin Sports Talk" station. Great! I love programming to electronica, so I've set my "coding" Room to play the excellent station "Monstercat", and – just for kicks – set the OS to Dark Mode.

A quick demo of the apps and script in action.

But there's just one thing though… What about our other Spaces? In this demo, the script has been written to tell Broadcasts to automatically pause its playback when it goes to any other Room (and turn off Dark Mode).

For more ideas on what could be automatically triggered upon entering/leaving Spaces, check out this blog post! 💡

How it's done

First, you're going to need to have Broadcasts. Check it out, and if you like it, grab the full version (it's currently a $5 in-app purchase).

Next, you're going to need CurrentKey Stats (App Store link), which is free.

The tutorial video below will show you how to do everything from scratch in under five four minutes!

The steps in the video involve:

  1. Opening CurrentKey and Broadcasts.
  2. Adding the Stations you want in Broadcasts.
  3. Naming the Spaces you want in CurrentKey.
  4. Enabling AppleScript support in CurrentKey.
  5. Moving this script (modified for the Stations/Spaces you want), to CurrentKey's Scripts folder.
  6. Clicking OK on the Mac's permissions dialog so CurrentKey can talk to Broadcasts (and if you want the Dark Mode functionality, the System Preferences).

That's it!

For more about the other new features in CurrentKey Stats 3.0, check out the latest blog posts.

The idea had a minor splash on Twitter, and that was fun to see.

That advertisement on the Sports channel 😂
Categories
AppleScript CurrentKey Stats

Power-user tutorial: Set up banner notifications that will tell you the name of the Space you just moved into!

Since CurrentKey Stats' launch, users have often asked for a way to see their Spaces'(Rooms') names without clicking the menubar icon. The most recent request was just yesterday. The commenter said: "Hi just tried ur app. Its a nice start but if you dont show the name somewhere i won't be bothered to click on the icon to see in which room i am".

Fortunately, there's an easy way to accomplish this! We will use CurrentKey's Room Change Alerts to issue push notifications! Here's what it will look like:

How to set it up:

  1. Open CurrentKey and give each Space a name.
  2. Enable AppleScript support in CurrentKey. (see below screenshot)
  3. Move this script to CurrentKey’s Scripts folder (There's a button to open this folder in the Background Services window). (See screenshot of file)
  4. Clicking OK on the Mac’s permissions dialog if prompted

Here is what the script looks like:

It's just that easy! You can do so many things with this powerful functionality, even give each of your Spaces a custom sound. More brainstorming fuel is available here.

Categories
AppleScript CurrentKey Stats

Assign specific scripts to run when you visit certain Mac Spaces and more 🖥 🎯

Most of us know about the MacOS feature called Spaces, and many of us love splitting our projects, work, and hobbies across our virtual desktops. Some find it unweildy because each Space is generic out of the box. Spaces don't come with the ability to be named or personalized other than setting a desktop background image.

CurrentKey Stats gives you a way to assign names, custom icons, and even custom auto-run scripts to each MacOS Space (the app calls Spaces "Rooms").

Now CurrentKey Stats recently gained the ability to trigger specific events upon entering/leaving specific Rooms, via the Background Services panel accessed in settings, as well as the ability to respond to AppleScript queries.

Between those two new features, the potential to personalize and automate workflows in Spaces skyrocketed. Want to set a custom internet radio station to each Space? You can do that!

Would you like to hook up your own scripts to CurrentKey's powerful app stats dataset? You can do that.

Check out the extensive list of brainstormed ideas as to what you could trigger with Room Change alerts – workflows that: automatically bring a specific app to the front? ✅ take a screenshot? ✅ mute the volume? ✅ toggle macOS dark mode? ✅ activate LED desk lights? ✅ trigger and IFTTT routine? ✅ selectively start/stop a timer based on what Room you are in or App is active? ✅ You can even pass parameters along to a Python script. Here's a tutorial.

Scripts can be aware of when you leave a Room, and can query what the list of active Rooms are. They can also ask a bunch of other questions about stats (like what is your most-used app today, or in a specific Room). Scripts can even request CurrentKey go to a specific Room.

Anyhoo, most people don't know that it's possible to create Space-specific automated workflows, and now you do! 😎

For a broader overview of CKStats, check out its homepage, App Store listing, or browse the demo below. Thanks!

Categories
AppleScript CurrentKey Stats

Advanced tutorial: running a Python script on Room changes

We all know about the MacOS feature called Spaces, and many of us love splitting our projects, work, and hobbies across our virtual desktops.

What if you could not just assign a name to each Space but also trigger custom events for each one too? A fun and simple example of this is assigning a custom Internet radio station to each one. I wrote about that here, and suggest you skim over that first.

The simplest way to trigger events is in AppleScript itself. Here's another basic explainer of how that works with CurrentKey Stats. When you change your Room, a file called "ck.scpt" will be called with the name of the new active Room.

From there, there's a ton of cool stuff you can trigger via AppleScript. If you have greater ambitions than AppleScript automation, then this post is for you.

There are legitimate reasons why you may want to call out into something more powerful, like a Python script.

A quick aside: since you're still reading this post and are clearly ambitious: CurrentKey also lets you fetch its stats and tell it to go to specific Rooms programmatically. Here's a post about that.

Let's talk about why you'd make a shell command from your ck.scpt file. Why? Because doing so means CurrentKey's Room Change alerts can be a springboard for basically anything. Here, the shell command is to run a python script that writes the latest Room name to a file. Think of it as a "hello world" demo.

Here is the ck.scpt that will run a Terminal command to fire off a Python script. https://github.com/sdailey/CurrentKey_AppleScripts/blob/master/RoomChangeAlertScripts/execute_a_python_script/ck.scpt

Here is the proof-of-concept Python script itself, which will write the latest roomName to a file: https://github.com/sdailey/CurrentKey_AppleScripts/blob/master/RoomChangeAlertScripts/execute_a_python_script/yoyo.py

The comments in the files themselves tell you where they need to be placed. Once they're in the right directories on your Mac, and you enable Room change alerts in your Background Services panel, the python script will be called with the Room name each time you change Spaces.

In the example ck.scpt file, you can substitute that command (which runs the python script) for any other shell command you can think of, and it should run it! Enjoy the power.

Categories
AppleScript CurrentKey Stats

CurrentKey Stats 3.0 resource pages

It finally felt like time to tackle a few ideas I'd been mulling for a long time for CurrentKey Stats. Here are links to a few resource pages on the new features:

Automatically Generated Stats Reports

And bi-directional AppleScript support, allowing for:

Room Change Alerts (which you can set to trigger custom events), and

Support for 14 AppleScript commands

Please let me know what you think @[email protected] or at currentkeystats at gmail.com

Enjoy! – Spencer