Skip to content

Instantly share code, notes, and snippets.

@cjwcommuny
Created November 6, 2021 07:43
Show Gist options
  • Save cjwcommuny/e3af17cc471fbff2c3823eaf968b207c to your computer and use it in GitHub Desktop.
Save cjwcommuny/e3af17cc471fbff2c3823eaf968b207c to your computer and use it in GitHub Desktop.
macOS Monterey Toggle Cursor Size
// see https://apple.stackexchange.com/a/430338/433504
function fn() {
const cursorSizeSmall = 1
const cursorSizeLarge = 4
const isRunningSystemPreferences = Application('System Preferences').running()
Application('System Preferences').panes.byId('com.apple.preference.universalaccess').anchors.byName('Seeing_Cursor').reveal()
const process = Application('System Events').processes.byName('System Preferences')
while (process.windows.length == 0) {}
const window = process.windows[0]
while (window.groups.length == 0) {}
const group = window.groups[0]
while (group.tabGroups.length == 0) {}
const tabGroup = group.tabGroups[0]
while (tabGroup.sliders.length == 0) {}
const slider = tabGroup.sliders[0]
if (slider.value() == cursorSizeSmall) {
slider.value = cursorSizeLarge
} else {
slider.value = cursorSizeSmall
}
if (!isRunningSystemPreferences) {
Application('System Preferences').quit()
}
}
fn()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment