Forked from stephancasas/sonoma-text-insertion-point-downgrade.jxa.js
Created
September 16, 2024 15:48
-
-
Save hym3242/9e33a980bdebdeb42ef311e73bd283d6 to your computer and use it in GitHub Desktop.
Disable Sonoma Text Insertion Point ("Cursor" / "Caret")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ? '😃' : '🫤'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment