Return to Blog

Brandon Him

instagram/@codewithhim

Creator and Tech Enthusiast

Development

How to Create a Shortcut to Restart the Fitbit OS Simulator

By Brandon Him
May 18th, 2020

Do you know what's the most difficult thing about Fitbit Development, this:

image

When you notice the app is side loading, but gets stuck... you'll feel the impending doom. On top of this, when you hit "Try Again", you get confronted with a 50/50 gamble of a never ending spinner.

Do not fret, I'll be showing you how you can simply create a shortcut to restart your application.

Easy/Lazy Method

npm preview

First off, I've created a simple open-source CLI helper that is easier than 1,2,3. If you are using Node, simply just run npm install -g fitbit-sim-restart.

After installing the module, all you need to do is run fitbit-sim-restart in your terminal window, and magic!

Less Easier Method w/ Keyboard Shortcut (Mac OS Only)

Now if you want to learn to create your own script and assign your own Mac shortcut, then let's learn how we can quickly create a AppleScript and apply it to a key binding.

Go to Search > Type Automator > Make a new Quick Action > Select Run AppleScript

quick action

run appplescript

Let's create a quick snippet to close the app, you should see this pre-existing code:

on run {input, parameters}
    (* Your script goes here *)
    return input
end run

Let's add a line to close the app, below the (* Your script goes here *):

quit app "Fitbit OS Simulator"

This will tell the OS to close the application called "Fitbit OS Simulator" -- as you can see AppleScript is very human readable.

Now let's add a line to reopen the app.

tell application "Fitbit OS Simulator" to activate

We use the tell method, because it's the standard for opening applications, if you were to use open app "Fitbit OS Simulator" we would actually receive an error as this is used for Documents.

Let's put it together:

on run {input, parameters}
    (* Your script goes here *)
    quit app "Fitbit OS Simulator"
    tell application "Fitbit OS Simulator" to activate
    return input
end run

run appplescript

Let's save it as "Fitbit Simulator Restart", and bind it to a shortcut.

Now go to System Preferences > Keyboard > Shortcuts.

shortcut

Select Services in the sidebar, and scroll down to "General", you should see "Fitbit Simulator Restart" assigned to "none"

Double click "none", and apply any keybinding you please.

Next, we need to allow Automator to run, so let's go to:

System Preferences > Security > Privacy > Accessibility > Click Lock > Check Mark Automator > Save Lock

shortcut

Awesome! We completed everything we need to now activate a simple shortcut to restart your Fitbit OS Simulator!