Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stephancasas/236f543b0f9f6509f5fe5878de01e38a to your computer and use it in GitHub Desktop.
Save stephancasas/236f543b0f9f6509f5fe5878de01e38a to your computer and use it in GitHub Desktop.
Disable Sonoma Text Insertion Point ("Cursor" / "Caret")
#!/usr/bin/env osascript -l JavaScript
const App = Application.currentApplication();
App.includeStandardAdditions = true;
const kCFPrefsFeatureFlagsDir = '/Library/Preferences/FeatureFlags/Domain';
const kCFPrefsFeatureEnabledKey = 'Enabled';
const kUIKitDomainPrefsTemporaryPath = '/tmp/UIKit.plist';
const kUIKitRedesignedTextCursorKey = 'redesigned_text_cursor';
function run(_) {
const dict = $.NSMutableDictionary.new;
const enabled = $.NSMutableDictionary.new;
enabled.setValueForKey(false, kCFPrefsFeatureEnabledKey);
dict.setValueForKey(enabled, kUIKitRedesignedTextCursorKey);
const error = $();
dict.writeToURLError(
$.NSURL.fileURLWithPath(kUIKitDomainPrefsTemporaryPath),
error,
);
if (typeof error.js != 'undefined') {
return `🫤: ${error.localizedDescription}`;
}
return App.doShellScript(
[
`mkdir -p '${kCFPrefsFeatureFlagsDir}'`,
`mv '${kUIKitDomainPrefsTemporaryPath}' '${kCFPrefsFeatureFlagsDir}'`,
].join(' && '),
{
administratorPrivileges: true,
},
).length == 0 ? '😃' : '🫤';
}
@stephancasas
Copy link
Author

@jorjGizer That looks correct. What might be causing an issue is the file ownership. I'm not certain, but I think that root needs to be the owner for the file to take effect — such is the way that launchd handles certain property lists, too. Try changing ownership with:

sudo chown root /Library/Preferences/FeatureFlags/Domain/UIKit.plist

@jorjGizer
Copy link

I do this and now I have root owner
total 8
drwxr-xr-x 3 root wheel 96 9 фев 17:59 .
drwxr-xr-x 3 root wheel 96 9 фев 17:39 ..
-rw-r--r-- 1 root wheel 272 9 фев 17:59 UIKit.plist

I reboot my Mac, maybe I forgot smth, but I want to hide this.
Снимок экрана 2024-02-09 в 18 44 32

@zdravnick
Copy link

Hi, maybe somebody knows how to change the cursor to block in TextEdit (mac osX Sonoma). Thanks!

@stephancasas
Copy link
Author

@zdravnick The systemwide insertion point doesn’t offer a block-type presentation style, so a feature like that would need to be implemented in the application itself or in a custom input method.

@zdravnick
Copy link

you're right. But I have no idea how to do this...

@dittlebop
Copy link

dittlebop commented May 30, 2024

Thank you for taking the time to put this together. When I copy it in, I get the message
zsh: event not found: /usr/bin/env
And the caps lock feature still displays.

I'm very new to using the terminal window, and have no real history of monkeying around with such things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment