AppleScript to Toggle Desktop Widgets

I’m a fan of the new Sonoma Desktop Widgets. However, I also make a living making screencasts and having all those widgets on screen can sometimes be a pain. There is a setting you can toggle under the Desktop & Dock settings:

The problem with this, of course, is that it’s a pain in the neck to get there. Who wants to do all that mousing and clicking? I wanted to automate this button so I can run a script that sets me up for screencasting and, among other things, turns off Desktop Widgets. So here’s a script that does just that. This was built with help from the AppleScript Sensei himself, Sal Soghoian. Below is a link to the zipped script file, as well as the script in plain text. I run it as part of a Keyboard Maestro macro that I’ve tied to a keyboard trigger. Enjoy.


tell application "System Settings"
	activate
	reveal anchor "Widgets" of pane id "com.apple.Desktop-Settings.extension"

	repeat
		set currentPane to get current pane
		if currentPane is pane id "com.apple.Desktop-Settings.extension" then
			exit repeat
		else
			delay 1
		end if
	end repeat
end tell

delay 1

tell application "System Events"
	tell process "System Settings"
		set targetControl to checkbox "Show Widgets" of group 6 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
		click targetControl
	end tell
end tell

tell application "System Settings" to quit

Widgets and Wallpapers on macOS Sonoma (MacSparky Labs)

Now that I’ve installed the Sonoma beta on my production machine, it’s time to share some Sonoma tricks with you. In this video, I explain how to add and customize Widgets on the desktop, and I show you some of the new wallpapers and how they look on the Lock Screen, and reveal my favorite so far.

Geek Meter 1️⃣ 2 3

Widgets and Customization

If Apple only knew …

With the recent release of iOS 14, many folks have been enjoying customizing the look of their iPhones. It is crazy how apparent the demand was for customization once Apple lowered the bar enough for anyone to do it independently. I love that this trend has put my friend David Smith on the top of the app charts with Widgetsmith, but I like even more that this has let users feel a closer connection to their technology.

Stephen Hackett explains why stodgy nerds shouldn’t know widget shame. I want to take it a step further and remind us all to think back to the first time we customized our technology. I used to have an Atari ST that I skinned to look like a Mac. Then when I got a Mac, I UI skinned it to look like a space ship console. Before there was an iPhone, I had a Treo phone that had Mac icons on it. As I sit here, I have replaced the icons of folders on my Mac with custom icons.

Customizing your technology is fun. Whether you are 9 or 90, you often sit at a computer to do work. Why not make it fun and delightful? I hope Apple is taking note. Indeed, I hope that has added a few entries to that big whiteboard in Cupertino. Specifically:

  • Replacing our App icons is cool. Making users go through Shortcuts to do so is not. Why not make it easier (and faster)?

  • Limiting each widget to one application feels like an unnecessary constraint. Wouldn’t it be cool if multiple apps can donate to a single user-customizable widget the same way apps can donate data to Shortcuts? We could make widgets that combine data from the apps most important to us.

  • David Smith’s app, Widgetsmith, can change the widget based on the time of day. We should be able to do that with all widgets, the same way you can now change Apple Watch faces based on the time of day via Shortcut automation. Also, speaking of Apple Watch …

  • Custom watch faces would be just as popular with Apple Watch owners as custom widgets are with iPhone owners. Please, Apple, give us custom Apple Watch faces.

The explosion of creativity with widgets on the iPhone has let the genie out of the bottle. Whatever faction inside Apple has been arguing for more user customization just got a lot more leverage in those Cupertino planning meetings. I sure hope they use it.