Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Enable the "Open in Low Resolution" setting for an arbitrary application in macOS
# Some notes about using this script:
# - Configure the application path and bundle id below
# - This script needs to be run as the user you need to set the checkmark for
# - The setting will not take effect until they log out and log back in at least once
import os.path
from Foundation import NSHomeDirectory, CFPreferencesCopyMultiple, CFPreferencesSetMultiple, kCFPreferencesAnyUser, kCFPreferencesCurrentHost, NSMutableDictionary, NSURL, NSURLBookmarkCreationMinimalBookmark, NSMutableArray
lowres_app_path = u'/Applications/'
lowres_app_id = u''
# -----------------------------
# create the bookmark data
app_url = NSURL.alloc().initFileURLWithPath_(lowres_app_path)
bookmark, error = app_url.bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(NSURLBookmarkCreationMinimalBookmark, [], None, None)
# check if the file exists already
ls_prefs = os.path.join(NSHomeDirectory(), u'Library/Preferences/')
ls_prefs_plist = ls_prefs + u'.plist'
if os.path.isfile(ls_prefs_plist):
# read it in
current_prefs = CFPreferencesCopyMultiple(None, ls_prefs, kCFPreferencesAnyUser, kCFPreferencesCurrentHost)
# make a new dictionary
current_prefs = NSMutableDictionary()
# Get any existing key or a new blank dict if not present
magnified = current_prefs.get(u'LSHighResolutionModeIsMagnified', NSMutableDictionary())
magnified_editable = NSMutableDictionary.dictionaryWithDictionary_(magnified)
# Build our values
options = NSMutableArray.alloc().init()
# A value of 3 = enabled, value of 2 = disabled
magnified_editable[lowres_app_id] = options
# Update the setting
update_dict = NSMutableDictionary()
update_dict[u'LSHighResolutionModeIsMagnified'] = magnified_editable
result = CFPreferencesSetMultiple(update_dict, None, ls_prefs, kCFPreferencesAnyUser, kCFPreferencesCurrentHost)

This comment has been minimized.

Copy link

gsnedders commented May 15, 2018

@pudquick Hey! This looks exactly like what I've been looking for; any chance of you attaching a license to this?


This comment has been minimized.

Copy link

gingerbeardman commented Aug 8, 2020

I used PlistBuddy in an Alfred workflow

/usr/libexec/PlistBuddy -c "Set :LSHighResolutionModeIsMagnified:org.openscad.OpenSCAD:1 3" ~/Library/Preferences/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.