sc
Scott avatar
ttwillsey

Mail Weekly Reads Script Command

Raycast

Part of the Raycast series

As I mentioned previously, I have a Weekly Reads page that I set up to make it easier for me to share articles with my dad and brother (and anyone else who cares), complete with RSS feed. But let’s be real, neither of them wants to be bothered with my feed because they have stuff to do and we already have a tradition of emailing links to each other.1

Last night I created a Raycast Script Command that looks at the markdown file for my latest Reads update, parses and reformats it for email, and mails it out to them. It looks like this:

#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Mail Weekly Reads
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.icon
# @raycast.argument1 { "type": "text", "placeholder": "Subject" }
# @raycast.packageName Website
# Documentation:
# @raycast.author scott_willsey
# @raycast.authorURL https://raycast.com/scott_willsey
subject=$1
# Find the latest file in the specified directory
latest_file=$(ls -t ~/Sites/scottwillsey/src/content/reads | head -n1)
echo "Processing file: $latest_file"
# Read the contents of the file, remove YAML front matter, and modify markdown links
content=$(awk '
BEGIN { in_frontmatter=0; }
/^---$/ { in_frontmatter = !in_frontmatter; next; }
!in_frontmatter { print; }
' "/Users/scott/Sites/scottwillsey/src/content/reads/$latest_file")
content=$(echo "$content" | perl -0pe 's/\*\*\[(.+)\]\((.+)\)\*\*\n\n(.+)/$3 → $1 – $2\n/gm')
echo "Content after regex replacement:"
echo "$content"
# Escape the content for AppleScript
escaped_content=$(echo "$content" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/`/\\`/g' -e "s/'/\\'/g" -e 's/$/\\n/' | tr -d '\n')
# Pass the escaped content to the AppleScript
osascript <<EOD
on run
set theContent to "$escaped_content"
tell application "Mail"
set theFrom to "me@mine.com"
set theTos to {"dad@dads.com", "brother@brothers.com"}
set theCcs to {}
set theBccs to {}
set theSubject to "$subject"
set theSignature to ""
set theAttachments to {}
set theDelay to 1
set theMessage to make new outgoing message with properties {sender:theFrom, subject:theSubject, content:theContent, visible:false}
tell theMessage
repeat with theTo in theTos
make new recipient at end of to recipients with properties {address:theTo}
end repeat
end tell
send theMessage
end tell
end run
EOD

It takes one parameter when I run the script so that I can give the email a cutesy custom subject (another idea I stole from my brother).

RaycastMailWeeklyReadsScriptCommand

Then it parses the latest file in my web project’s /src/content/reads directory, replaces markdown links with “commentary → link title – link” for each link and following commentary paragraph in the page, and gives that to an AppleScript to send the mail.

From this markdown page that generates the individual HTML reads page:

ReadsMarkdown

To this email that gets sent to my long-suffering family members:

ReadsEmail

It’s simple and effective. You can do this and make your family hate you too.

Footnotes

  1. Fine, it’s my brother’s tradition and I’m stealing it, much to his annoyance I’m sure.

Raycast Extensions I Use

Raycast

Part of the Raycast series

Introductionum

Recently Niléane of MacStories wrote about the Raycast extensions she uses in Adding to My Mac’s Swiss Army Knife: A Raycast Extension Roundup - MacStories. I learned about a couple good ones that I wasn’t aware of, but I also thought I would list Raycast extensions I use here, along with a little bit about why for each of them.

The Listium

So here they are in alphabetical order-ish:

1Password

I actually underutilize this one. It allows for opening items in various ways (in 1P or in a browser), generating passwords, and more, but I’m so familiar with 1Password’s own keyboard shortcuts that I forget about the Raycast extension.

Append Clipboard

This is a really outstanding extension that lets you prepend or append text to whatever’s on your clipboard with a pre-specified separator. It sounds like something I should use all the time. I’d actually forgotten I had this one installed. 🤦‍♂️

Apple Mail

Stop me if you’ve heard this one before – here’s an extension that sounds really useful and I just don’t use it. But I should! Checking for new mail, composing an email, sharing finder items to mail, seeing recent or important mail, these are all possible with this extension. I think with most of these it’s a matter of building muscle memory.

Apple Reminders

I actually have used this extension! The Apple Reminders extension lets you use natural language to set reminds, in addition to allowing you to view and complete them.

Brew

Hi, Homebrew users! Want a quick way to see what you’ve installed with Homebrew, or search for and install new formulae and casks? You can do so from wherever you’re at in macOS with this extension.

Change Case

I use this extension all the time. Capital Case, camelCase, lower case, PascalCase, snake_case, UPPER CASE, and more… select your text and have at it. I love this one.

Clean Keyboard

I just started using this one today. It effectively locks your keyboard until you type ^ U (Ctrl+U) to unlock it, in order to allow you to clean the keyboard without deleting your home folder or sending an obscene message to your boss.

CleanShot X

I’m currently a heavy CleanShot X user and this extension has a ton of useful CleanShot X commands, but once again… the old muscle memory. If you picked up on the fact that I’m primarily writing this article to benefit myself, you win the prize of knowing how insightful you are.

Clipboard Formatter

I use this all the time to clear formatting from items in the clipboard. It comes in handy for certain things I have to enter into excel, for example. Yes, you can tell excel to paste in content only, but this is faster for me, and it’s also useful anywhere you need formatting removed.

ColorSlurp

I use ColorSlurp for color picking and therefore I use this extension to quickly launch it and grab colors, but truthfully I may very well switch to Color Picker instead. In fact, I’m doing it right now.

Copy Path

Oh, I love this one. For example, I just had a finder window with some pdfs in it open and I ran this extension and it gave me /Users/scott/Documents/BlueDragonfly/Sophos/ET15 - Sophos Central Endpoint Protection v5.0 - Engineer/ET15-Sophos-Central-5.0v5-Engineer-EN/01 Sophos Central Overview/ on my clipboard. You can’t beat that!

Cron Description

You ever look in crontab and see something illegible like */15 * * * * python3 /usr/local/sbin/scripts/wanipy/main.py --env prod > /dev/null and you can’t remember what */15 * * * * means? Well, it means run this thing every 15 minutes, and I know that because (well, I already knew that particular one) Cron Description told me!

cURL

I know I installed this for a reason, I just don’t remember what it was. Anyway, it lets you use curl to make an HTTP request, complete with custom headers.

Custom Folder

I haven’t actually used this yet, but this one helps you create custom folder icons and apply them to folders you want to customize. It’s not something you’ll use every day, but it’s pretty cool.

Date Format Converter

Input a date string and then format it into any standard date format you like. It’s that simple.

Dynamic Font Size

If you’ve ever struggled with the CSS clamp function, you’ll like this one. You just enter your parameters, like min and max font sizes and min and max viewport sizes, and it’ll generate your clamp for you.

Easings

Another CSS helper. You can quickly copy an ease-in like cubic-bezier(0.55, 0.085, 0.68, 0.53); or you can create your own custom CSS transitions.

Format JSON

Lets you take JSON that’s not formatted nicely and indent everything properly.

GIF Search

Search for GIFs, favorite them, paste them in various ways to various targets.

Git Commands

Search and learn what different git commands do.

GitHub CLI Manual

Helpful if you need to interact with GitHub using a CLI, this utility lets you search for commands and then opens the GitHub manual page for them.

GitHub

Too many commands to list here, but it lets you work with GitHub in various ways. I guess that’s pretty self-evident.

GitHub Repository Search

This is for searching for repos on GitHub and quickly opening them (and really quickly opening repos you’ve visited before).

Google Chrome

I primarily use this for searching Chrome history, but you can search bookmarks, open windows, search tabs, and more.

Google Translate

I have never used this. Maybe I should uninstall it.

HTTP.cat Status Codes

This reminds you what all those pesky HTTP status codes mean AND gives you a cute cat to go with it. The internet was invented for cats. Don’t ever forget it.

Iconify — Search Icons

Here’s a good one that I should really use more. Search for icons and get the svg source code.

Ingredients Lister

I can see why I installed this, but I can’t see why I haven’t used it yet. This grabs web pages or YouTube videos and gets recipe ingredients from them for you.

Installed Extensions

If you’re thinking “I bet Scott used this extension to list what extensions he has installed”, you win a Ferrari!! I mean, someone else is going to have to provide the Ferrari. But I’ll let you win it if they’re willing to give it. 🤷

Link Cleaner

Clean those dirty links of yours, dammit!! Auto-scrubs tracking and referral crap off URLs for you.

Lorem Ipsum

Occasionally while mocking up some web idea I’ll toss in some Lorem Ipsum text, and this is a super quick way to do it.

Markdown Reference

I kind of installed this one because I could. I don’t think I’ve ever needed to use it. I use Markdown all the time but it’s pretty simple.

Menubar Calendar

I like this one for letting me pop open a tiny calendar quickly and for also showing me upcoming calendar items.

Notion

I use Notion. I use Raycast. You’d think I’d use this extension. Truth is, I keep forgetting about it (again). I should at least use the search feature, that would save me some time getting to it in the Notion app itself.

Open Link in Specific Browser

This is actually kind of cool, but I never use this because I’ve created default browser script commands that I use all the time.

Open Path

Here’s another one I have but never used. It looks like a way to open things in various apps depending on what the source link is, but… I have no clue.

Pins

I like this one. It’s just another way to get to things – I use it to create pins to Finder folders, mostly.

Pipe Commands

This lets you take various input sources and pipe them into a script command. You’d think I would use this all the time.

Placeholder

Grabs placeholder images from Lorem Picsum. Pretty handy.

PromptLab

A super useful extension for creating AI prompts to be used with Raycast AI.

Quick Calendar

Yep, another calendar extension, but this one just pops open a bigger calendar window to look at.

Quick Event

Um, I’m going to let you guess whether or not I’ve ever actually used this, but it’s for quickly creating calendar events.

Random Data Generator

This is a really cool one for quickly generating random dates, CC numbers, text, email addresses, and more.

Raycast Icons

Have not used. There, are you happy? This is for looking at various Raycast-specific icons.

Reddit Search

I might use this more if 1.) I remembered I have it, 2.) I don’t hate Reddit so much. Does everyone there have to write like they’re 13?

Regex Tester

I should use this more and see if it’s any good. I’m spoiled by BBEdit’s RegEx playground feature so I never do.

Remove Paywall

I’m not going to overtly state why I use this one, but I use it quite a bit. I don’t constantly end-run around paywalls on the same sites over and over. It’s for one-offs.

Ruler

This is a cool one for measuring stuff on the screen. I used this the other day to make a screenshot of a certain form item on a web page vs. what the form item plugin thought the minimum width should be. Yes, I could have used the browser developer tools for that, but this was easier for the client to look at and instantly get the point.

Safari

Like its Chrome counterpart, I mostly use this for Safari history search, but it’s also good for searching tabs and the reading list (which I do use).

ScreenOCR

I don’t think I have ever used this because I’ve discovered the OCR reading shortcut in CleanShot X, but it is pretty cool.

Search npm Packages

I don’t really use npm for a lot these days because most stuff I script I now script in Python. I of course use npm with things like Astro, but I don’t need to search for anything for that.

Set Audio Device

This is a great one to use to make sure you’re using your podcast mic instead of the built-in laptop one or whatever else will pick up the cricket in your kitchen.

Shell

I don’t know. It looks cool, but I’ve never used it. I have Warp, what the hell, guys. Get off my back. 😄

Speedtest

A handy way to run the ever popular speedtest.net speed test.

Summarize YouTube Videos with AI

I keep meaning to show this one to Peter. An AI watches videos so you don’t have to. Problem is, AIs are shite at summarizing (imnsho).

System Monitor

I have no clue why I have this installed, because I use and love iStat Menus.

Text Shortcuts

I use this a LOT while writing and programming, and I LIKE IT. Quick and easy text transformations of all types.

Timezone Converter

I use this when I remember to. Mostly I use it before I’ve had coffee for trying to see what people on the east coast might be doing.

Type Snob

VERY specific text utility for curly quotes, real em and en dashes, etc.

Unicode Symbols Search

I don’t always search for unicode symbols, but when I do…

Unix Timestamp

Unix timestamps were created by the devil, so I guess this is really just a conduit to hell. But it’s a pretty cool one.

URL Tools

URL encoding and decoding made fun and easy!!!

UUID Generator

Who does not need a UUID from time to time? No one, that’s who. If you think you don’t, well now you know why your life is falling apart.

Visual Studio Code - Project Manager

I genuinely have no idea why I have this instead of the general purpose Visual Studio Code extension. Maybe I was drinking beer the night I installed this.

Warp

I LOVE WARP!!! I always forget I have this installed though. I know. I’m a loser.

Web Converter

I do webby things a lot. I should probably try to remember I have this installed. “Hey, Scott. You have this installed.”

Wordle

I used to play this, but then I paid for Lex.games and have never looked back.1

World Clock

Somewhere in the world, it’s X o’clock!! Find out where!! Also (and even cooler), put in an IP address and find out what time it is for whatever has that stupid IP.

YouTube

Search YouTube videos and channels like it’s 1999. I don’t know why I said that. I’m not even sure when YouTube was first created.

YouTube Downloader

Speaking of YouTube… download all of YouTube, one video at a time!!!!

Summarium

That’s pretty much it for now. I’m always open to revisiting things and uninstalling some things and installing other things. Most likely in a year from now, not much will have changed though.

Footnotes

  1. I love Lex.games. Don’t even get me started.

Weekly Reads

My brother likes to send emails to dad and I containing links of interesting things he’s read recently, replete with commentary of his own. I used to send one link at a time to them, then I tried his approach, and now I generally send a link at a time again.

Instead of this nonsense, I thought I’d create a Weekly Reads page to add Weekly Reads posts to, complete with its own RSS feed.

I may call it Weekly Reads, but I may add reads more than weekly or much less than weekly. I don’t know. Don’t pressure me! I have a lot going on! 😄

I need to create some links to it so people can find it and know it exists, but it’s there! It works!

Updated Sessions Raycast Script Command

Raycast

Part of the Raycast series

As you may know, I created a Raycast script command to trigger what I call “sessions”, which are really just setting up the Mac to perform different tasks, such as podcasting or “normal” general use. At the time, I was using Raycast for window management, so my script command referenced Raycast window management layouts. Now I’m using Moom for window management, so I needed to update it to call my Moom layouts instead.

In the process, I decided to steal even more from Robb Knight’s App Mode Raycast script command and use his method of killing all apps before activating a session and having an array of default apps that I always want open. It’s almost the same exact script now.

The updated version looks like this:

#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Session
# @raycast.mode fullOutput
# Optional parameters:
# @raycast.icon /Users/scott/Scripts/Raycast/icons/app-mode.png
# @raycast.argument1 { "type": "dropdown", "placeholder": "Session", "data": [ { "title": "Home", "value": "home" }, { "title": "IT", "value": "it" }, { "title": "Podcast", "value": "podcast" }, { "title": "Podcast Edit", "value": "podcastedit" } ] }
# @raycast.packageName Utils
# Documentation:
# @raycast.description Set up a workflow session
# @raycast.author scott_willsey
# @raycast.authorURL https://raycast.com/scott_willsey
open raycast://extensions/raycast/system/quit-all-applications
sleep 3
CORE=(1Password Messages Mail Safari)
TYPE=$1
for value in "${CORE[@]}"
do
open -a "$value"
done
if [ "$TYPE" = 'home' ]; then
open 'raycast://script-commands/set-default-browser-safari'
sleep 2
open -a Warp
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Speakers"
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Microphone" -t "input"
osascript ~/Scripts/applescript/apply_moom_layout.scpt "Home"
exit
fi
if [ "$TYPE" = 'it' ]; then
open 'raycast://script-commands/set-default-browser-chrome'
sleep 2
open -a "Google Chrome"
open -a Warp
open -a Slack
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Speakers"
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Microphone" -t "input"
osascript ~/Scripts/applescript/apply_moom_layout.scpt "IT"
exit
fi
if [ "$TYPE" = 'podcast' ]; then
open 'raycast://script-commands/set-default-browser-safari'
sleep 2
open -a "Audio Hijack"
open -a Farrago
open -a Bear
open -a FaceTime
/opt/homebrew/bin/SwitchAudioSource -s "Elgato Wave XLR"
/opt/homebrew/bin/SwitchAudioSource -s "Elgato Wave XLR" -t "input"
osascript ~/Scripts/applescript/apply_moom_layout.scpt "Podcast"
exit
fi
if [ "$TYPE" = 'podcastedit' ]; then
open 'raycast://script-commands/set-default-browser-safari'
sleep 2
open -a "Logic Pro X"
open -a Finder ~/Documents/Podcasts/FwB
/opt/homebrew/bin/SwitchAudioSource -s "Elgato Wave XLR"
osascript ~/Scripts/applescript/apply_moom_layout.scpt "PodcastEdit"
exit
fi

You can see that because my so-called “IT” session sets Chrome as the default browser, I’m compelled to set Safari as my default browser for every other session type. I supposed I could just move that out to the top and have it called no matter what, and then immediately reversed if the session type is “IT”. You can read about my default browser script commands here.

The reason for the sleep commands is that without them, running the Session script command would result in some timing issue in which only some of the apps would open, but not all of them. I was able to solve the problem by putting in a sleep after killing all applications and after setting the default browser.

Calling Moom layouts using AppleScript commands (osascript) is possible because the author of Moom supports AppleScript calls to the program. I wish more programmers would think of their apps as potential links in a workflow chain like this.

Moom 4

Mac

Part of the Mac series

You may have noticed, as you’ve wandered the site, that I’m a bit of a Raycast fan. You may, therefore, imagine that I use the Raycast window management tools to move and arrange windows . And it’s true. Well, it was true. Then Many Tricks released Moom 4, the update to their popular Moom window manager app.

Historically, I’m a window manager serial monogamist. Like any other type of utility, there’s a wide range of approaches to this task in the available third-party apps. Some let you draw your window size and location on the screen, some have keyboard shortcuts for instantly popping things into specific locations, some let you save multi-window layouts, and many various combinations of these things. Raycast does two of these things. Moom does all of these things.

At first glance, you might think Moom is a slower way to manage windows. One of its signature controls is the Keyboard Controller, which you activate via a hotkey (in my case ^⌥⌘Space). Once it’s onscreen, you can use the keys indicated on its cheat sheet to move and/or resize your focused window per the options available.

Moom Keyboard Controller

You can also customize the options that appear at the top of that list, and the bottom section will always show any actions you’ve assigned single-key hotkeys for. For example, based on my arrangement above, pop open the Keyboard Controller with ^⌥⌘Space and then hit 3 and you’ll move the foreground window to the left third size of the screen.

Another great way that Moom allows for window control is something I think may be unique to it – a palette of window management buttons that shows up when you hover over one of the stoplight buttons in the window’s top left corner. You can specify in Moom’s settings which of the three buttons to hover over to get the palette, as well as which window commands are available.

Moom Palette Menu

These are all great and dandy, but Moom has freeform sizing and moving options too. You can configure Moom hotkeys that allow you to glide the cursor over a window to move it or to resize it. These options sure beat trying to find an empty spot to click on a title bar filled with tabs, or to find the little grab handles at the edge of the window. Apple really hates onscreen controls and the native resizing controls can be slow to manipulate.

And then there’s the grand champion of all freeform resizing, the Moom grid. It allows you to quickly draw out a window size to fit anywhere on a grid. You can set the number of rows and columns in the grid, which gives you quite a bit of range in window size granularity.

Here’s what it looks like to drag out the shape you want to resize your window to on the grid:

Moom Grid Resize

And here’s the resulting resized Safari window.

Moom Post Resize

Despite all these great window management options, sometimes good old fashioned hotkey controlled instant resizing and moving is still the best way to quickly tile windows. Moom allows for that. You can create custom window sizes and locations and assign hotkeys to them. You can also make window layouts with multiple windows that can be applied instantly. Window layouts can be set to apply to specific apps only, or to whatever windows are handy when you apply the layout.

You can see some of my window settings complete with hotkeys in my Moom settings window below.

Moom Size Position Settings

And in a bit of good news for me, Moom commands can be activated via AppleScript. Thanks to this, I modified my Sessions Raycast script command to accommodate setting window layouts using Moom instead of using Raycast’s window management tools. I’ll show you that in a future post.

I do like the window management commands in Raycast, and there’s always an argument for having one less application running in memory. But Moom is more versatile (and frankly more fun to use), and Raycast lets me disable its window management, and so Moom 4 seems like a no-brainer to me.

At least for now.

The Green Economy Is Hungry for Copper-and People Are Stealing, Fighting, and Dying to Feed It

This is not a normal topic for me on this site, but since I blather on about technology nonstop and make my living thanks to it, it’s important to highlight the very real downsides it brings. For example, the current push towards electrification of everything is ramping the planet’s need for copper, and copper means exploitation, death, and environmental disaster to people in many parts of the world.

If this doesn’t sound very interesting, the human element of the story is intriguing. Just the part about Robert “Toxic Bob” Friedland illustrates how wild this story really is:

By the early 1980s Friedland had teamed up with some Vancouver-based financiers and moved into the world of mining, hustling for small gold outfits. He made headlines in 1992 when a Colorado gold mine he had previously overseen (as its parent company’s CEO) leaked toxic heavy metals into a nearby watershed, earning him the nickname “Toxic Bob.” In the meantime he had also discovered a major gold deposit in Alaska and an even bigger nickel deposit in Canada, which he later sold for more than $3 billion. Friedland has been a major player in the industry ever since. (He also has a sideline in movies, helping to produce Crazy Rich Asians and other films. Another fun Friedland fact: This summer, he bought a scenic California estate from Ellen DeGeneres for a trifling $96 million.)

Interestingly, at one point this guy ran the commune Steve Jobs lived on in Oregon in the ’70’s. Steve eventually left, disillusioned with what he saw as Toxic Bob’s materialism. Not to put too fine a point on it, but Toxic Bob was far from the only hippy idealist who transformed into an uber capitalist, convincing themselves in the process that it was for the good of humanity and not just their own ballooning bank accounts.

Linked post: The Green Economy Is Hungry for Copper—and People Are Stealing, Fighting, and Dying to Feed It | WIRED

Automating Sessions With Raycast Script Commands

Raycast

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.

Raycast Sessions Script Command

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).

Podcast Session Window Layout Command

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:

Podcast Session Window Layout in Action

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:

#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Sessions
# @raycast.mode silent
# Optional parameters:
# @raycast.icon ../icons/app-mode.png
# @raycast.argument1 { "type": "dropdown", "placeholder": "Choose Mode", "data": [ { "title": "Podcasting", "value": "podcasting" }, {"title": "Stop Podcasting", "value": "stopp"} ] }
# @raycast.packageName Utils
# Documentation:
# @raycast.description Set apps and devices for specific work session types
# @raycast.author scott_willsey
# @raycast.authorURL https://raycast.com/scott_willsey
TYPE=$1
if [ "$TYPE" = 'podcasting' ]; then
/opt/homebrew/bin/SwitchAudioSource -s "Elgato Wave XLR"
/opt/homebrew/bin/SwitchAudioSource -s "Shure Beta 87a & Farrago" -t "input"
open raycast://customWindowManagementCommand?name=Podcasting
shortcuts run "Scott Desk Lamps Toggle"
osascript -e 'tell application "Amphetamine" to start new session with options {duration:3, interval:hours, displaySleepAllowed:false}'
exit
fi
if [ "$TYPE" = 'stopp' ]; then
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Speakers"
/opt/homebrew/bin/SwitchAudioSource -s "Studio Display Microphone" -t "input"
osascript -e 'quit app "Farrago"'
osascript -e 'quit app "Bear"'
osascript -e 'quit app "Audio Hijack"'
osascript -e 'quit app "FaceTime"'
shortcuts run "Scott Desk Lamps Toggle"
open raycast://customWindowManagementCommand?name=Safari%20Center
osascript -e 'tell application "Amphetamine" to end session'
exit
fi

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.