Photoshop Clear Mode Toggling

Usually when listing grievances concerning Photoshop or any Adobe product the typical complaint is about the subscription model. Believe me, I’m not a fan. This post isn’t about that; but first I do want to air some grievances.

I have a soft spot for Adobe Photoshop because it is how I truly began digital painting. Photoshop is a venerable program, having been released to the public since 1990. I’ve used it since 2.0 in 1991 on the Macintosh II. I was just a kid. There were no layers, only one undo, and no custom brushes; but it was magic. I would spend hours upon hours drawing random things in it with a mouse and later scanning my drawings in to manipulate them. I would use it for what it was designed for — to manipulate photographs — but the truth is that what I wanted to do was draw on a computer, and that wasn’t feasible for at least half a decade or more from then when I bought the first model Wacom Intuos tablet. I could finally draw on my computer.

Back in the day we used Photoshop because we had to. It was the only name in town for that sort of thing that was worth using. Painter is an application that is nearly as old as Photoshop is which is designed to more accurately mimic natural media and is geared more toward digital painting. Unfortunately, it is janky and incredibly slow; in fact it always has been despite decades of development and changing hands between companies. Deluxe Paint predated Photoshop which is something Amiga fans love to point out, but it was a bitmap pixel editor meant largely for low color 8-bit 2D 1980’s video game graphics; it was even developed by Electronic Arts. This is not a knock at pixel artists, but I’m talking about painting here. All of the other alternatives back then are not worth mentioning. Today, there are numerous good alternatives for painting. Adobe even has another application which is purely meant for digital painting, but it’s only available on iOS and also Windows — if the Windows computer has a built-in pen display. Professionals who have paid upwards of $3000 for Cintiq pen displays are shit out of luck.

Photoshop has always been marketed and treated by Adobe mostly for photo manipulation. Digital painting, despite being important for two of the biggest entertainment industries in the world, has largely been treated as the equivalent of a red-headed stepchild. Bones were thrown at digital artists as far back as Photoshop 6 when what we think of the Photoshop brush engine today had its beginnings. Since then we’ve gotten arbitrary canvas rotation in CS4, the nearly useless mixer brush in CS5, finally a color wheel in Photoshop CC 2018, and sometime since then a clear blending mode for brushes.

Why Use Photoshop, Then?

A lot of the applications linked to above have surpassed Photoshop when it comes to digital painting, but I personally often find myself gravitating towards Photoshop because of its familiarity but also because manipulation tools are just as important when digitally painting as it is when manupulating photographs; they are either awkward to use, slow, or nonexistent in applications meant for digital painting. Also, if I’m starting something and Photoshop is already open I will often just use Photoshop; sometimes it truly is a whimsical choice. Out of the listed applications above I use Krita the most of all because its brush engine is more customizable than anything else I’ve seen. It is fast when painting even with large canvas sizes, but adjustments like levels, curves, and gradient maps need a lot of work. Krita contains a lot of quality of life improvements when it comes to user experience that I miss when using Photoshop. Krita doesn’t have a separate tool for erasing. You use a brush and set eraser mode when needing to erase; it’s an eraser button on the top horizontal bar. There is also an erase blending mode. To make things extra useful eraser mode can be toggled by simply pressing b. Recently in Photoshop a clear blending mode was added to do exactly this, but Adobe didn’t deign it worthwhile to assign a shortcut for it or to even make it possible to do so. Deep in Adobe Photoshop CC 2020’s release notes it states that ~ should toggle between brush and eraser mode using the same brush, but as far as I can tell that has never worked. I wanted a way to toggle this. I figured something out and thought I should share it.

AppleScript to the Rescue

AppleScript is a macOS feature that has existed as far back as I can remember, and it (sadly as will be seen in a bit) is probably my first introduction to programming, writing scripts to prank my dad on the aforementioned Macintosh II using a book a friend of his let us have for reference. I should mention that this trick is Mac-only, and I haven’t a clue what the equivalent on Windows is — or if there even is one.

To toggle between blending modes one must click on the dropdown on the top horizontal bar and manually select the blending mode. Nobody ain’t got no time for that. AppleScript has accessibility features that allow it to click buttons and select things in an application’s UI and after testing that Photoshop was somewhat exposed to this API I was able to come up with a script to toggle it for me:

tell application "System Events" to tell process "Adobe Photoshop 2022"
	tell application "Adobe Photoshop 2022" to set _currentTool to current tool

	if _currentTool is equal to "paintbrushTool" then
		set _focusedWindow to null
		repeat with i in windows
			if focused of i is true then
				set _focusedWindow to i
				exit repeat
			end if
		end repeat

		if description of _focusedWindow is equal to "standard window" then
			set theWindow to null
			repeat with i in windows
				-- Photoshop doesn't expose anything good to identify the window.
				-- Its position will always be at the top, so let's use that...
				if position of i is equal to {0, 24} then
					set theWindow to i
					exit repeat
				end if
			end repeat

			if theWindow is not null then
				set brushMode to pop up button 1 of theWindow
				set currentMode to value of brushMode

				set newMode to "Clear"
				if currentMode is equal to "Clear" then
					set newMode to "Normal"
				end if

				click brushMode
				click menu item newMode of menu 1 of brushMode
			end if
		end if
	end if
end tell

That’s great, but there’s nothing in there about assigning the script to a keyboard shortcut.

Enter skhd

skhd is a third-party daemon that runs in the background that intercepts keypresses and performs shell commands. macOS has a built-in global shortcut feature that’s in the Keyboard system preferences pane, but it’s quite limited in the commands it can assign and what can be assigned. Skhd is designed for people who want to transform macOS into window managers like i3 using things like yabai. Yabai is in fact developed by the same developer as skhd, but I use it without yabai despite its original intent. My keyboard doesn’t have an eject key like typical macOS keyboards do so the control + shift + for turning the screen off doesn’t work. With skhd I can assign control + shift + esc to pmset displaysleepnow, allowing the feature to be used on my escape key less keyboard. One can execute AppleScript through the shell, so skhd can be used in much the same way.

Skhd can be installed and started through Homebrew:

brew install koekeishiya/formulae/skhd
brew services start skhd

Configuration is easy, being a single file located at ~/.skhdrc. Documentation may be found on skhd’s GitHub page as to everything that can be done. I’ll instead focus just on what is necessary to execute the AppleScript above. Here is an excerpt of my configuration:

ctrl - e [
    "Adobe Photoshop 2022" : osascript ~/Scripts/Photoshop/"Toggle Clear Brush Mode".scpt

This snippet above tells skhd to bind control + e to osascript ~/Scripts/Photoshop/"Toggle Clear Brush Mode".scpt but only when Adobe Photoshop 2022 is the active application. This assumes the script is stored in ~/Scripts/Photoshop/Toggle Clear Brush Mode.scpt, so if wanting to store it somewhere else make sure the path is changed in ~/.skhdrc.

If everything goes okay pressing control + e in Photoshop should cause the dropdown to toggle between Clear and Normal blending modes.


macOS has a lot of security features to keep arbitrary code from being executed without the user’s permission. Sometimes macOS’ security features while well-intentioned feel to be less thought out and especially far more annoying than they should be, and this is certainly one of those situations. When running skhd for the first time when starting it with Homebrew above it should cause a dialog box to appear asking for permission to access accessibility features; grant it permission. If one doesn’t grant it permission that dialog box won’t appear again, and anything skhd does will fail silently. It’s poorly designed as the user should never be able to put themselves in a situation where something they believe should work won’t without no obvious way to rectify it. This is a normal occurrence in Windows but hasn’t been in macOS. In case the dialog was accidentally dismissed, permission may be granted again by going to AppleSystem Preferences…Security & PrivacyPrivacyAccessibility. Clicking the + button will allow for selecting the executable to grant permission. If installed through Homebrew skhd will be located at /usr/local/bin/skhd.