Automating Sessions With Raycast Script Commands
Part of the Raycast series
In the past, I used a menubar utility called Bunch to start and stop my podcast session setup. But this was before I started using Raycast, and now that I already use Raycast to run lots of scripts and automations, I decided to do this with Raycast too.
I took inspiration from Robb Knight’s App Mode Raycast script command and created one called Sessions. Like Robb’s, it uses a dropdown to choose what “session” I want to run. It’s a bit of a weird name, I guess, because I have one called “Stop Podcasting”, which doesn’t really seem like a session, but more like a lack of a session.
When I run the Sessions script command, I currently have two choices: Podcasting or Stop Podcasting.
The Podcasting option runs a Raycast Window Management Command which opens specific apps (Audio Hijack, Farrago, Safari, Bear and FaceTime) and puts their windows in specific locations on the screen using a preset Window Layout.
This is what the Raycast Window Layout Command looks like. The apps are Audio Hijack (top left), Farrago (bottom left), Bear (center), FaceTime (top right), and Safari (right half).
The script command also sets the audio output to my Elgato Wave XLR, which has my podcasting headphones plugged into it, and sets the audio input to a Loopback audio device that combines my podcasting mic and Farrago soundboard into one input device. Finally, it starts an Amphetamine session, which keeps the display from sleeping if I don’t touch the mouse or keyboard for awhile while podcasting, and toggles my desk lamps on using a Shortcuts shortcut.
Here’s what it looks like on my Apple Studio Display after running the Sessions script command:
The Stop Podcasting option sets the audio output and input to my Studio Display’s speakers and mic, closes Audio Hijack, Farrago, Bear, and FaceTime, centers Safari on the screen again, and stops the Amphetamine session. It also toggles the desk lamps.
Here’s the full script command:
Raycast script commands can be written in bash script, Apple Script, Swift, Python, Ruby, or JavaScript (Node.js). This one is a bash script, and the Podcasting option very simply uses bash commands to run a bunch of other utilities: SwitchAudioSource, to set audio output and input, a Raycast custom window management command to open my podcast session apps and place their windows per a custom layout, a shortcut to toggle my desk lamps, and finally an inline Apple Script (osascript) to start an Amphetamine app session so the display can’t sleep.
The Stop Podcasting option runs similar commands plus several Apple Script calls to close the apps that were opened by the Raycast custom window layout in the Podcasting option.
Script commands are both a great reason to use Raycast and a great tool for automation if you already do use Raycast.