Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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

@aol-nnov I opted to keep the code instead of going the one-liner route in order to preserve the UI-based privilege escalation dialogue.

Given that a sizable number of users reading this have likely never used Terminal, I anticipated the next question being "I ran the command you shared, but it won't let me type my password."

@aol-nnov
Copy link

@stephancasas that makes sense...

Also, while fighting recent MacOS updates, ha-ha, I've found a marvellous repo with nerd-ish defaults. https://github.com/kevinSuttle/macOS-Defaults

May be, you'll find it useful too! 😉

@stephancasas
Copy link
Author

@aol-nnov Thank you! I'll take a look at this for sure! :)

@MrRod
Copy link

MrRod commented Feb 5, 2024

Loving this! Thanks so much @stephancasas !

Any ETA for the app you mentioned you would write if Apple didn't find any security issues (which they didn't according to your reddit post)? I'm happy to do any testings!

@jorjGizer
Copy link

I did the script, I have an
ls -la /Library/Preferences/FeatureFlags/Domain
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 jorj_gizer wheel 272 9 фев 17:59 UIKit.plist

What should I do next? Nothing was changed

@stephancasas
Copy link
Author

@jorjGizer Did you reboot your Mac?

@jorjGizer
Copy link

jorjGizer commented Feb 9, 2024

Yes, 2 times. I have Sonoma 14.3.1

@stephancasas
Copy link
Author

@MrRod Not at the moment. I've had some pressing issues with work that needed attention. I'll update the Reddit post and sent a post on X when something's ready to be published.

@stephancasas
Copy link
Author

@jorjGizer Run cat /Library/Preferences/FeatureFlags/Domain/UIKit.plist and please paste the output here.

@jorjGizer
Copy link

Снимок экрана 2024-02-09 в 18 26 25

@MrRod
Copy link

MrRod commented Feb 9, 2024

@MrRod Not at the moment. I've had some pressing issues with work that needed attention. I'll update the Reddit post and sent a post on X when something's ready to be published.

Thank you for your answer, I'll keep an eye on both Reddit and X :)

@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!

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