Fixing SWA calendar items with Shortcuts

During the Snell Talk segment of this week’s episode of Upgrade, Jason Snell said some nice things about a script I wrote several years ago to improve calendar entries for upcoming Southwest Airlines flights. It came up because recently his Hazel setup for triggering the script had stopped working, and he had to make some changes.

Listening to the show, I was reminded that my iOS translation of the script had stopped working and that I’d planned to figure out a solution. I did figure out a solution this afternoon, but it wasn’t anything like what I expected.

To rehash the problem briefly, when you book a flight on Southwest, the website gives you an opportunity to download entries for the flights to your calendar.

Southwest calendar entries

If you’re working on a Mac, the calendar entries are downloaded as .ics files. Double-clicking the files will install them in Calendar. On iOS, the entries go directly into Calendar.

This is nice, but the calendar entries themselves aren’t as useful as they should be. For example, the entry title is always Southwest Airlines Confirmation XXXXXX, where the XXXXXX part is the confirmation number. While it’s nice to have the confirmation number in the title, the rest of it takes up too much space. And the useless information is at the front, so it crowds out the the only part that’s of any value.

Default Southwest calendar entry

A better title would have the flight and confirmation numbers—the most important information—in the title in a compact form that you can always see. Making that change is one part of the script.1

Improved Southwest calendar entry

The other part is a Southwest-specific addition. Southwest doesn’t have assigned seats. You choose your seat when you board the plane, and your place in line to board is determined when you check in. Online check-in opens up exactly 24 hours before your scheduled flight time. So to get a good place in line, it behooves you to check in as soon as you can.

Hence the value of adding an alert to the calendar entry. It can fire off shortly before check-in time to remind you to get your Southwest app open and ready.

On the Mac, I have a Python program called swicsfix that edits the downloaded .ics files to make them conform to my taste. I’ve used it for years and so has Jason.

A year or two ago, I adapted swicsfix to run in Pythonista on iOS. It was helpful when I was traveling and didn’t have a Mac handy. But Southwest has seemingly made some changes to its website recently, and the iOS version of swicsfix is now downloading a weird HTML file instead of the expected .ics. After looking over the situation, I decided I don’t have the web programming chops to fix it.

Turns out there’s an easier solution: add the default calendar entries that Southwest provides and then fiddle with them using Shortcuts. Strictly speaking, Shortcuts doesn’t allow you to edit a calendar entry in place, but you can extract information from an existing entry, change it around to create a new entry to your liking, and then delete the original.

That’s what SWA Calendar Fix does. That link will download the shortcut. Here’s the code with commentary.

StepActionComment
1 SWA Calendar Fix Step 01 The important thing here is to look into the future for calendar entries whose titles start with “Southwest Airlines Confirmation” because that’s how the “native” entries come from Southwest. I’m not sure why I limited it to the next 30 days.
2 SWA Calendar Fix Step 02 Now we’re going to loop through the list of the entries returned by Step 1.
3 SWA Calendar Fix Step 03 These three steps get the confirmation number by getting the title…
4 SWA Calendar Fix Step 04 … breaking it into words…
5 SWA Calendar Fix Step 05 … and taking the last word. We’ll use this later to make the new title.
6 SWA Calendar Fix Step 06 We go through the same steps, starting with the location…
7 SWA Calendar Fix Step 07 … splitting it into words…
8 SWA Calendar Fix Step 08 … and taking the last word. This is the flight number.
9 SWA Calendar Fix Step 09 Now we use the flight and confirmation numbers to build the title of the replacement entry. It looks like SW 1234 (XXXXXX).
10 SWA Calendar Fix Step 10 We want the replacement entry to be in the same calendar…
11 SWA Calendar Fix Step 11 … and to have the same start date/time…
12 SWA Calendar Fix Step 12 … and end date/time.
13 SWA Calendar Fix Step 13 We create a date/time for the check-in alert that’s one day and 15 minutes before the flight.
14 SWA Calendar Fix Step 14 Now we build the replacement entry from all the pieces we’ve collected and assembled. It would be easier to edit the existing entry, but Shortcuts doesn’t provide an action for altering entries other than to remove them entirely.
15 SWA Calendar Fix Step 15
16 SWA Calendar Fix Step 16 Delete the original entries. You’ll be given a chance to cancel the deletion when the shortcut runs.

If the Add New Event action in Step 14 allowed the addition of two alerts instead of just one, it would be a complete and perfect replacement for swicsfix. And in only 16 steps. I’m beginning to think swicsfix on the Mac could be replaced with a fairly short JXA script (or AppleScript) that follows the logic of SWA Calendar Fix.

Update Mar 11, 2020 10:09 PM  Here’s an improvement to the shortcut.


  1. The redactions in these screenshots blunt my point somewhat, but I think you can still see the improvement.