Automate suspend/resume terminal with webooks by iOS shortcut app

Terminal doesn't have to be up and running while you don't work. (Unless you need to execute some jobs during the time). To save money and energy, you'd better stop the terminal when you don't use it and start it when you use it.

If you use an iOS device, like iPhone, you have the shortcut app to realize it. I'm going to explain how to do it.

Create shortcuts

1. Open Shortcut app

2. Go to Wazaterm top page after logging in. And show details of the terminal. You see the Webhooks section.

3. Using the info, create a shortcut.

  • Hostname: Yours
  • Username: Yours
  • method: POST
  • Request Body: JSON
  • action_type: resume or suspend
  • token: Your token code


Create Automations

Schedule

If you want to resume or suspend the terminal with time. For example, suspend terminal when my job is usually done at 17:30. Create New Automation with "Time of Day"

Location

If you want to resume or suspend the terminal with the location. For example, when you reach the office within 100m, then resume the terminal. This is a bit tricky because the "Arrive" or "Leave" trigger doesn't allow us to execute the action without asking before running. But you can use "Focus" to deal with this.

  1. Open "Settings" and go to "Focus"
  2. Open "Work" (or others if you want to have it)
  3. Add Schedule with location

Then go back to Shortcut app, Automation and set up.

Summary

I think there are other ways to deal with this but I use Location for resume terminal and schedule to suspend terminal. This is because my time to start job may change every day but the end of the day is fixed. Also, I sometimes leave the office to get food or something else, which should not suspend the terminal. Hope you can enjoy the automation with Wazaterm!