Thursday | 21 NOV 2024
[ previous ]
[ next ]

iPhone Shortcuts

Title:
Date: 2022-01-03
Tags:  

After reading an article about an author creating shortcuts to force them to do something healthy before letting them use social media, I decided to do the same thing! The article had a picture of the general idea of the shortcut and it is something that piqued my curiosity when I first read about it but I never found a reason to actually use shortcuts. This was a good excuse and it would help me stay off of TikTok and Instagram in the morning.

https://nick.comer.io/post/ios-shortcuts

The first thing I had to do was re-install the shortcuts app. Re-installing was straighforward and the app itself is quite intuitive. In the automation tab, you can start a new automation which let's you select the type of automation you want to run.

This let's you pick an event to run the automation against and so I chose to run in on an app. The next screen let's you pick which app to run on and if you want to run it on open or on close. In this case, I want a shortcut to automatically close tiktok if it is still before 12pm.

I select the app and then select the automation to run on open.

The next step is to add an action and the first action we add is the text box. The text box let's you either ask the user for input or fill it with some data that the iphone has. In my case, I want the date, specifically just the time. I also set the date format to not show the date and only show the short time which is 6:45.

The next step is to use the round number function which is an action in the shortcuts app that you can use to get the time converted into a number. It's pretty cool to see how the shortcuts app has all these programming functions but it's graphical and it uses a flowchart to program in. I never used a language like this so to me it was quite eye-opening.

The next step was to add an if statement and because the rounding function created a number, the if statement conditional will have the context of doing equality checks. So we can set the if statement to use the rounded number and the conditional of less than. We can then say 12 and voila! We have a branching to if the rounded number is less than 12, the next action we add will be the close app function. With that we are done!

Now the automation will make it so that if I open tiktok before 12, it will auto close it. This worked perfectly but I soon became unable to use tiktok after 12pm. This was because I use a 12 hour clock and so the rounding wasn't taking that into account. I change my time to be 24 hours as this was easier than trying to parse out the am or pm of the time. The other thing was I disabled the ask on run option as by default, automations will ask you before running. This seems to be for a safety thing which is great. Automations will also always show a notification when they run so everytime I open tiktok even if it's after 12, it will always say the automation ran. This is a pretty safety feature as well, this way someone can't install an automation without you knowing.

These shortcuts seem like a really fun way doing programming, especially on my phone. I'm curious to see some more advanced stuff and debugged seems like it would also be an adventure. I made a few other simple shortcuts like sending a message when I open an app, I used this to figure out what the various date and time formats looked like. There's probably a better way as my debugging was basically opening instagram and waiting for the text message to come. This is basically shell scripting but on my phone which is neat. I think that is a big reason why I like shortcuts because it is the ultimate glue language on the phone just like shell scripting is on linux. It helps that shortcuts looks really polished and comes with a lot of functionality.