Example #1
0
def writePlist(timestamp, writePlistPath):
    sippysip = []
    if os.path.isfile(writePlistPath):
        sippysip = CFPreferencesCopyAppValue('Events', writePlistPath)
        if sippysip:
            sippysip = NSMutableArray.alloc().initWithArray_(sippysip)
        else:
            sippysip = []
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
    else:
        sippysip.append(timestamp)
        CFPreferencesSetAppValue('Events', sippysip, writePlistPath)
Example #2
0
 def _set_macos_pref(self, key, value):
     """Sets a preference for domain"""
     try:
         CFPreferencesSetAppValue(key, value, BUNDLE_ID)
         if not CFPreferencesAppSynchronize(BUNDLE_ID):
             raise PreferenceError("Could not synchronize %s preference: %s" % key)
     except Exception as err:
         raise PreferenceError("Could not set %s preference: %s" % (key, err))
Example #3
0
 def _set_macos_pref(self, key, value):
     """Sets a preference for domain"""
     try:
         CFPreferencesSetAppValue(key, value, BUNDLE_ID)
         if not CFPreferencesAppSynchronize(BUNDLE_ID):
             raise PreferenceError(f"Could not synchronize preference {key}")
     except Exception as err:
         raise PreferenceError(f"Could not set {key} preference: {err}")
Example #4
0
def set_pref(key, value, domain=BUNDLE_ID):
    """Sets a preference for domain"""
    try:
        CFPreferencesSetAppValue(key, value, domain)
        if not CFPreferencesAppSynchronize(domain):
            raise PreferenceError("Could not synchronize %s preference: %s" %
                                  key)
    except Exception, err:
        raise PreferenceError("Could not set %s preference: %s" % (key, err))
Example #5
0
def set_app_pref(pref_name, value):
    """Sets a value in Preferences.
    Uses CoreFoundation.
    Args:
       pref_name: str preference name to set.
       value: value to set it to.
    """
    CFPreferencesSetAppValue(pref_name, value, BUNDLE_ID)
    CFPreferencesAppSynchronize(BUNDLE_ID)