---
title: And then there were interactive Bunches
date: 2021-01-14 12:44
slug: and-then-there-were-interactive-bunches
categories:
- Code
tags:
- bunch
- snippet
- scripting
- music
---

![Banner image](https://brettterpstra.com/uploads/2021/01/OptionalSnippetsHeader-rb.jpg)

Here's the latest stuff in [Bunch](https://brettterpstra.com/projects/bunch/) 1.3.1!

This is all the result of a combination of new (better) ADHD meds (I refer you to the last couple episodes of [Overtired](https://overtiredpod.com/)) and the fact that the latest developer seed of Big Sur fixed the [blurry PDF issue](https://brettterpstra.com/2020/11/12/marked-2-big-sur-and-blurry-pdfs/) that I've been dedicating an inordinate amount of time to working around, so I suddenly have a little extra time in my day. Thank you Apple. For fixing what you broke, I mean. But still, I'm grateful.

(I'll do an official announcement post on the Marked bug when this fix makes it into the stable release and is available to everyone.)

So what's new with Bunch?

<!--more-->

### Do Not Disturb for Big Sur

First, I _think_ I've come up with a solution for Do Not Disturb commands under Big Sur. This needs further testing but---to the best of my knowledge---Bunch doesn't break anything in the process. It's a more complicated trick than it was in earlier versions of the OS. It used to just be a boolean stored in the preferences. Now it's a plist stored as data in a preference key and modifying it gently has proven difficult. 

The end result is a kind of brute force hack that seems to be working. So now using `(dnd on)` or `(dnd off)` in your Bunch should once again function under Big Sur. Please let me know if you run into any issues.

I have to include a standard disclaimer here: I am not responsible for anything Bunch breaks on your system, or any damages suffered as a result[^worstcase]. I will work to fix anything wrong, though, serious or not.

[^worstcase]: Probably worst case: If something goes wrong, you might have to obliterate your notification preferences, which can lead to having to allow a bunch of apps to send notifications again. But that probably won't happen.

### Clear Single Checkmarks

If you have "Toggle Bunches" or "Single Bunch Mode" enabled under Preferences, Bunch adds a checkmark in the menu when you launch a Bunch. Clicking a checked item will then close the Bunch. Mostly for the sake of debugging Bunches, I have an option in the menu to Clear Checkmarks, allowing you to launch a Bunch again without quitting it.

I've expanded this to allow clearing a single checkmark by Option-clicking a checked Bunch in the menu.

### AppleScript "Raw" Bunch Text

There's a new [AppleScript command](https://brettterpstra.com/projects/bunch/#applescript) for directly processing text as if it were read from a Bunch file. The command is `process text "YOUR TEXT"` and correlates to the [raw URL method](https://brettterpstra.com/projects/bunch/#urlhandlerraw).

This can be used for sending simple commands or reading text in, modifying it, and then executing it.

### Optional Snippets

I saved my favorite bit for last: a new feature I'm calling "optional snippets." I wanted to add some interactivity to a Bunch so that I didn't have to make two different bunches when only one part of it was different. I've started this process by allowing simple Yes/No choices when loading [snippets](https://brettterpstra.com/projects/bunch/#snippets). I may expand this at some point to allow more complex dialogs, but this approach fits well with the spirit of Bunch syntax[^syntax].

[^syntax]: Which is to say "complicated enough that even I have to frequently reference the docs, yet still somehow elegant in its simplicity."

This does mean that if you want to make a single app or script optional, you have to create a snippet with a single item, but you can just [add a fragment](https://brettterpstra.com/projects/bunch/#fragments) for that.

You just put a query at the end of a snippet import line, like so:

	<MySnippet.snippet ?"Load My Snippet?"

When you open the Bunch, it will pop up a dialog that asks you "Load My Snippet?" (text defined by what's in the quotes). If you click "Yes," then the contents of the snippet load. If not, it's skipped. This dialog will appear each time the Bunch is launched.

Focusing this feature on snippets allows a single dialog to affect a whole block of Bunch items without having to pollute the syntax with a whole logic system. You can simply make any part of the Bunch optional by extracting it into a snippet and adding a query.

There are cases where I'd like to be able to select from a list, but the complexity of adding syntax for that is a non-starter. There are options, though, as you'll see in the "Alternative Interactivity" section of this post.

#### An Optional Snippet Example

Ok, so here's an example Optional Snippet using a range of Bunch features.

I have a "Coding" bunch that launches the basics like Tower, Xcode, Sublime Text, and iTerm. Within that Bunch, I have an optional snippet for playing background music. Depending on my mood and state of mind, music is either going to be the best idea or the worst. So I'd like the option to go either way when switching to the Coding context.

##### In Coding.bunch

In `Coding.bunch` I have a line like this:

	<useful.snippets#Coding Spotify ?"Play Coding Music?"

When I open this Bunch, it asks me "Play Coding Music?". If I confirm, it executes the "Coding Spotify" fragment of my `useful.snippets` file.

##### In the Snippet

Here's the Coding Spotify fragment of `useful.snippets`:

	#[Coding Spotify]
	& workflows/Play Spotify URL
	- URL=spotify:playlist:3cSpIL4Q0H3uqdBMbT6c9x
	- Autoplay=true
	!* tell application "Spotify" to pause

The `&` line calls an [Automator Workflow](https://brettterpstra.com/projects/bunch/#automator), and the `!*` [runs an AppleScript command](http://brettterpstra.com/projects/bunch/#applescript) only when the Bunch closes.

##### The Workflow

Here's the "Play Spotify URL" workflow:

![Screenshot of Play Spotify URL Workflow](https://brettterpstra.com/uploads/2021/01/spotifyworkflow2.jpg)

[View image full size](/uploads/2021/01/spotifyworkflow2-full.jpg)

The Workflow has variables set up for `URL` and `Autoplay`. `URL` is where I pass the Spotify URI for a playlist, and `Autoplay` can be set to  false to prevent the music from starting immediately. (You'll also note a Bunch variable, which is required for any Bunch workflow.) 

The above snippet passes parameters to the `URL` (in this case the Spotify URI for my Coding Music playlist) and `Autoplay` variables (set to true because I've made the interactive choice to play music). Using variables in this way makes the workflow easily reusable and allows me to play different playlists for different Bunches.

Bonus, the script also does a nice fade in if Autoplay is true.

Here's a copy of the [Play Spotify URL Workflow](http://assets.brettterpstra.com/PlaySpotifyURL.workflow.zip) if you just want to download it and play with it yourself.

##### The AppleScript

The last line of the snippet tells Bunch to run an AppleScript when closing the Bunch to pause Spotify. Alternatively, I could have Spotify launch and quit with the Bunch by just including `Spotify` on a line. If I'm in the mood for music, though, I probably want Spotify to stay open, but I still want that particular playlist to pause when I leave the Coding context.

Hope that makes sense.

#### Alternative Interactivity

It is, of course, feasible to have a Bunch call your own AppleScript with more complex dialogs, and have that script call other Bunches based on selections using AppleScript or the URL handler.

If you wanted to fork a Bunch to load another Bunch selected from a list, you could write an AppleScript like this:

	set bunchChoices to {"Coding", "Comms", "Podcasting"}
        set theBunch to choose from list bunchChoices with prompt "Select a Bunch:" default items {"Comms"}

	tell application "Bunch" to open bunch theBunch

Then call that AppleScript from the main Bunch using a `*` command. Or build the choices out to execute raw text, which happens to work with snippets and variables...

	tell application "Bunch"
            process text "<useful.snippets#Spotify\n- url=spotify:playlist:37i9dQZF1E35F7NsH3aWbs"
        end tell

### Enough for Now

That's the Bunch news for now. See all the latest and download Bunch [on the project page](https://brettterpstra.com/projects/bunch/).

## Bunch

Project: [Bunch](https://brettterpstra.com/projects/bunch.md)

- [Bunch is back for Golden Gate](https://brettterpstra.com/2026/09/14/bunch-is-back-for-golden-gate.md): 2026-09-14
- [Put all the web browsers in your Dock](https://brettterpstra.com/2026/03/06/put-all-the-web-browsers-in-your-dock.md): 2026-03-06
- [Brett's Favorites 2025](https://brettterpstra.com/2025/12/29/bretts-favorites-2025.md): 2025-12-29
- [Leader Key and Bunch](https://brettterpstra.com/2025/04/30/leader-key-and-bunch.md): 2025-04-30
- [Brett's Favorites 2024: Personal Projects](https://brettterpstra.com/2024/12/31/bretts-favorites-2024-personal-projects.md): 2024-12-31
- [Automating the Dimspirations workflow](https://brettterpstra.com/2024/04/01/automating-the-dimspirations-workflow.md): 2024-04-01
- [Web Excursions for February 29, 2024](https://brettterpstra.com/2024/02/29/web-excursions-for-february-29-2024.md): 2024-02-29
- [Marked and Bunch updates for Sonoma](https://brettterpstra.com/2023/10/05/marked-and-bunch-updates-for-sonoma.md): 2023-10-05
- [Brett's Favorites 2022 - Personal Projects](https://brettterpstra.com/2022/11/30/bretts-favorites-2022-personal-projects.md): 2022-11-30
- [A better Shortcuts command for Bunch](https://brettterpstra.com/2022/08/08/new-in-the-bunch-beta.md): 2022-08-08
- [Project Updates July 2022](https://brettterpstra.com/2022/07/31/project-updates-july-2022.md): 2022-07-31
- [BetterTouchTool and Stream Deck](https://brettterpstra.com/2022/07/02/bettertouchtool-and-stream-deck.md): 2022-07-02
- [Bunch 1.4.8](https://brettterpstra.com/2022/06/14/bunch-1-dot-4-8.md): 2022-06-14
- [Bunch: Focus Modes and other tips](https://brettterpstra.com/2022/03/22/bunch-focus-modes-and-other-tips.md): 2022-03-22
- [He's Doing it again...](https://brettterpstra.com/2022/02/21/doing-it-again-dot-dot-dot.md): 2022-02-21
- [Bunch 1.4.6](https://brettterpstra.com/2021/11/23/bunch-1-dot-4-6.md): 2021-11-23
- [Just your average project update and wellness check-in](https://brettterpstra.com/2021/09/24/just-your-average-project-update-and-wellness-check-in.md): 2021-09-24
- [A Keyboard Maestro macro for cross-linking Markdown docs](https://brettterpstra.com/2021/09/01/keyboard-maestro-markdown-linking.md): 2021-09-01
- [Let's get crazy with BetterTouchTool and Touch Bar Simulator](https://brettterpstra.com/2021/07/21/crazy-bettertouchtool-touch-bar-simulator.md): 2021-07-21
- [Jay Miller: Using Bunch for Creating Newsletters](https://brettterpstra.com/2021/07/06/jay-miller-using-bunch-for-creating-newsletters.md): 2021-07-06
- [Bunch 1.4 is here](https://brettterpstra.com/2021/06/19/bunch-1-dot-4-is-here.md): 2021-06-19
- [A Bunch update, and a Sublime Text package](https://brettterpstra.com/2021/06/08/a-bunch-update-and-a-sublime-text-package.md): 2021-06-08
- [The latest on the Bunch beta](https://brettterpstra.com/2021/03/17/the-latest-on-the-bunch-beta.md): 2021-03-17
- [Bunch gets scheduling (and lots more)](https://brettterpstra.com/2021/02/02/bunch-gets-scheduling-and-lots-more.md): 2021-02-02
- [Another round of Bunch Updates](https://brettterpstra.com/2021/01/19/another-round-of-bunch-updates.md): 2021-01-19
- [And then there were interactive Bunches](https://brettterpstra.com/2021/01/14/and-then-there-were-interactive-bunches.md): 2021-01-14
- [Bunch Updates](https://brettterpstra.com/2021/01/06/bunch-updates.md): 2021-01-06
- [Bunch Snippet Fragments](https://brettterpstra.com/2020/09/17/bunch-snippet-fragments.md): 2020-09-17
- [Bunch and the Stream Deck](https://brettterpstra.com/2020/09/16/bunch-and-stream-deck.md): 2020-09-16
- [Podcasting with Bunch](https://brettterpstra.com/2020/09/15/podcasting-with-bunch.md): 2020-09-15
- [Using Moom with Bunch for window management](https://brettterpstra.com/2020/09/14/using-moom-with-bunch-for-window-management.md): 2020-09-14
- [Bunch gets audio control](https://brettterpstra.com/2020/09/10/bunch-gets-audio-control.md): 2020-09-10
- [Bunch 1.2.2](https://brettterpstra.com/2020/01/14/bunch-1-dot-2-2.md): 2020-01-14
- [Bunch 1.2: no more redundant Bunches](https://brettterpstra.com/2019/09/24/bunch-1-dot-2-no-more-redundant-bunches.md): 2019-09-24
- [Bunch's latest abilities...](https://brettterpstra.com/2019/08/16/bunchs-latest-abilities.md): 2019-08-16
- [Bunch and Timing.app](https://brettterpstra.com/2019/07/02/bunch-and-timing.md): 2019-07-02
- [Bunches LaunchBar Action quick fix](https://brettterpstra.com/2019/06/12/bunches-launchbar-action-quick-fix.md): 2019-06-12
- [Bunch for the menu bar](https://brettterpstra.com/2019/06/11/bunch-for-the-menu-bar.md): 2019-06-11
- [Better Bunch for LaunchBar](https://brettterpstra.com/2019/06/10/better-bunch-for-launchbar.md): 2019-06-10
- [The latest Bunch stuff](https://brettterpstra.com/2019/06/04/the-latest-bunch-stuff.md): 2019-06-04
- [Another day, another Bunch](https://brettterpstra.com/2019/05/20/another-day-another-bunch.md): 2019-05-20
- [Bunch gets its own URL scheme](https://brettterpstra.com/2019/05/17/bunch-gets-its-own-url-scheme.md): 2019-05-17
- [Bunch 1.0.4 with URL schemes support](https://brettterpstra.com/2019/05/16/bunch-1-dot-0-4-with-url-schemes-support.md): 2019-05-16
- [Launch AND quit apps with Bunch 1.0.2](https://brettterpstra.com/2019/05/15/launch-and-quit-apps-with-bunch-1-dot-0-2.md): 2019-05-15
- [Bunch, a batch app launcher for your Dock](https://brettterpstra.com/2019/05/14/bunch-a-batch-app-launcher-for-your-dock.md): 2019-05-14
- [Best of 2017: Real stuff](https://brettterpstra.com/2018/01/22/best-of-2017-real-stuff.md): 2018-01-22
- [Best of 2017: Nerding out on macOS](https://brettterpstra.com/2018/01/15/best-of-2017-nerding-out-on-macos.md): 2018-01-15

---

Brett is a writer and developer living in Minnesota, USA. You can follow him as ttscoff. This content is supported by readers like you. [More about Brett](https://brettterpstra.com/contact.md), including social links.

Copyright © 2026 Brett Terpstra. All rights reserved.
