Sleepy Time(r): Scratching an itch...how to track music I listen to before going to sleep automatically.
Last week I wrote about an “itch” I was trying to scratch. That “itch” resulted in a cool Shortcut I created that I’ve named Music Hub (an homage to Federico Viticci’s awesome Shortcut Music Bot). The Shortcut affords me the opportunity to choose from a menu of 4 different music choices. When I select one of these choices, “it” opens and my Timery Music timer simultaneously starts so I can time track my music consumption.
This week’s blog post is about another “itch” I refer to at the end of last week’s post; my interest in creating a Shortcut that would allow me to time track music before I go to bed without having to stop my Timery Music timer manually.
Specifically, the Shortcut I wanted to create would open a music selection, start the Apple Timer for the amount of time I want to listen to music while simultaneously starting my Timery Music timer and, 5 seconds before the Apple timer stops (this is important and will be explained later), close the Timery Music timer thus recording the amount of time I spent listening to music before going to bed without having to stop the Timery Music timer manually. Are you following this? I wasn’t sure I was going to be able to pull this off. I did a little bit of research and couldn’t find any documentation that anyone had figured out how to get a Timery timer to stop automatically within a Shortcut. I wasn’t going to let that deter me.
Before I started trying to figure this Shortcut out on my own I sought advice from 2 writers/podcasters I admire greatly, John Voorhees and Federico Viticci. In an email, I told them what I wanted to do and wondered if they knew if such a Shortcut was even possible. While I waited for them to reply, inspired by their curiosity in figuring such things out, I went about the task of trying to see if this was possible all on my own.
The first part of the Shortcut was simple enough, I needed to create a menu of the music choices I wanted to draw from. This picture shows the two music sources I picked; playlists from Apple Music. I only chose 2 because I was experimenting at this point and did not want to spend a lot of time putting playlists into the Shortcut only for it not to work.
The next step was to pick the “action” that would start the Apple Timer and decide on an amount of time I wanted the timer to run. This picture shows I decided on 20 minutes. Again…I was experimenting here. My thinking was, why try to have this run any longer if I was going to, a) fall asleep, and b) the Shortcut not work? That would only mean I’d have to fix things the morning after. Also shown in this picture is the “action” that triggers the Timery Music timer. My next hurdle was to figure out how to factor in how long to let the Timery timer to run and get it to stop automatically.
I searched the Scripting category and found an “action” called “Wait.” It only allows you to input seconds so, I did. 20 minutes times 60 seconds in a minute equals 1200 seconds. I thought…if I entered the exact number of seconds that the Timery timer would shut off just as the Apple Timer expired. I added the last “action,” the Timery “Stop the current time entry” “action” and gave it a test. It didn’t work. As you can see in this picture, the “Wait” “action” does not say 1200 seconds, it says 1195. Also, I added another “action,” the Shortcuts Run Stop Timery “action.” Both of these decisions were crucial to the workflow of this Shortcut. What I figured out was that the Shortcut needed time to stop the Timery timer (hence the decision to initiate things just before the Apple Timer stopped) and a way of knowing that I actually wanted it to stop the current time entry. Notice that there is a vertical line connecting the last 2 “actions.” This is the only way to get the Shortcut to work.
Scratch “itched!!” I’ve been using this Shortcut for a few days now; works every time…and most importantly…makes me super happy each time it works!!
I got an email from John Voorhees the other day saying he did not think there was a way to get this Shortcut to work. I wrote him back and told him I’d figured it out. I also shared my screenshots with him and invited him to give it a try.
It’s been so much fun trying to figure this out. I welcome you to use my screenshots as a model for how to create a similar Shortcut. In the meantime, I’ve created a copy of the Shortcut…a space to play so to speak. I’ve also increased the amount of time on the Apple Timer and might even add some other sleep time playlists to the original Shortcut.