Quickly Hiding Sonoma Desktop Widgets
I recently saw this post from MacSparky on quickly toggling widgets on the Sonoma desktop. David's use case is screencasting, of course, but being able to flick these helpful widgets away in a flash can help make your desktop a bit less distracting.
David's method uses GUI scripting via AppleScript's System Events. It works, but GUI scripts have always felt fragile to me so I went looking for a better way.
Doing the same with defaults
Turns out, you can achieve the same result in a "behind-the-scenes" fashion using macOS's defaults system:
defaults write com.apple.WindowManager "StandardHideWidgets" -bool "false" && killall WindowManager
You can wrap this up in a Keyboard Maestro script or whatever script-runner works best for you 1. Just don't forget to include the killall
part, or you won't see the effect of the change.
Hope this helps!
I'm partial to terminal aliases, so I can just type
widgets
at the command line to turn them on or off ↩