Skip to main content
  1. Posts/

macOS Folder Actions - Dismiss Notifications

·273 words·2 mins·
The Masked Farter
Author
The Masked Farter
😷 🍑 :dashing_away:
Table of Contents

Context
#

I recently switched to a CircuitPython-powered keyboard. The upside is that CircuitPython exposes a virtual removable drive that contains the code (code.py) that will execute on the device. In the case of the keyboard this involves setting up the keymaps, backlight, and some other more experimental features and settings. One downside to this setup is you need another keyboard to get yourself out of crashing changes to code.py. Then there’s one other downside that’s less critical but at least as equally annoying and the subject of this post. During the first week or two while assembling and configuring the keyboard, you’ll likely unplug the keyboard a lot. And unless you’re much more diligent than me, you’ll end up with a wall of DISK NOT EJECTED PROPERLY notifications.

Goals
#

  • Prevent or cleanup these disk notifications for specific devices.
  • Prefer something event-based rather than timer-based.

Solution
#

Script
#

Unfortunately, as is increasingly becoming the case, this required resorting to AppleScript and scraping UI elements. This script will look for specific UI elements within the “Notification Center” app and within those elements again filter for the specific text set at the top of the script. It will then pull the list of available actions on that UI element looking for a Close action and calling it.

Folder Action Setup
#

I copied the above script to ~/Library/Scripts/Folder Action Scripts. Then opened Finder and chose Go > Go to Folder... and went to /. You will probably need to tell Finder to show hidden files at this point, which is most easily done by tapping Command + Shift + . (that’s a period).

Related

Xpenology DSM 6.1.x on VMware ESXi 7
·713 words·4 mins
The Masked Farter
Docker Contexts & Synology
·2042 words·10 mins
Matthew P. Slanker
A place for various projects
·16 words·1 min
Matthew P. Slanker