def set_selfcontrol_setting(key, value, username):
    """ sets a single default setting of SelfControl for the provied username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    CFPreferencesSetAppValue(key, value, "org.eyebeam.SelfControl")
    CFPreferencesAppSynchronize("org.eyebeam.SelfControl")
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
def set_selfcontrol_setting(key, value, username):
    """ sets a single default setting of SelfControl for the provied username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    CFPreferencesSetAppValue(key, value, "org.eyebeam.SelfControl")
    CFPreferencesAppSynchronize("org.eyebeam.SelfControl")
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
def get_selfcontrol_settings(username):
    """ returns all default settings of SelfControl for the provided username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    defaults = NSUserDefaults.standardUserDefaults()
    defaults.addSuiteNamed_("org.eyebeam.SelfControl")
    defaults.synchronize()
    result = defaults.dictionaryRepresentation()
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
    return result
def get_selfcontrol_settings(username):
    """ returns all default settings of SelfControl for the provided username """
    NSUserDefaults.resetStandardUserDefaults()
    originalUID = os.geteuid()
    os.seteuid(getpwnam(username).pw_uid)
    defaults = NSUserDefaults.standardUserDefaults()
    defaults.addSuiteNamed_("org.eyebeam.SelfControl")
    defaults.synchronize()
    result = defaults.dictionaryRepresentation()
    NSUserDefaults.resetStandardUserDefaults()
    os.seteuid(originalUID)
    return result
Exemple #5
0
# Add new entries
for key, importedItem in importedData.iteritems():
    item = NSMutableDictionary.dictionary()
    item.setObject_forKey_(importedItem['enabled'], 'on')
    item.setObject_forKey_(key, 'replace')
    item.setObject_forKey_(importedItem['replacement'], 'with')
    items.addObject_(item)
    added += 1

# Update the preferences
prefs.setPersistentDomain_forName_(globalPrefs, '.GlobalPreferences')
prefs.synchronize()

# Release the preferences from memory
NSUserDefaults.resetStandardUserDefaults()

# Build notification userInfo object
userInfo = {}
userInfoEntries = []
for item in items:
    userInfoEntries.append({
                           'shortcut': item.valueForKey_('replace'),
                           'phrase': item.valueForKey_('with'),
                           'timestamp': int(time.time())
                           })
userInfo = {
    'IMKUserDictionaryUserInfoCurrentEntriesKey': userInfoEntries
}

# Makes our changes to apply immediately on running processes.
Exemple #6
0
# Add new entries
for key, importedItem in importedData.iteritems():
    item = NSMutableDictionary.dictionary()
    item.setObject_forKey_(importedItem['enabled'], 'on')
    item.setObject_forKey_(key, 'replace')
    item.setObject_forKey_(importedItem['replacement'], 'with')
    items.addObject_(item)
    added += 1

# Update the preferences
prefs.setPersistentDomain_forName_(globalPrefs, '.GlobalPreferences')
prefs.synchronize()

# Release the preferences from memory
NSUserDefaults.resetStandardUserDefaults()

# Build notification userInfo object
userInfo = {}
userInfoEntries = []
for item in items:
    userInfoEntries.append({
        'shortcut': item.valueForKey_('replace'),
        'phrase': item.valueForKey_('with'),
        'timestamp': int(time.time())
    })
userInfo = {'IMKUserDictionaryUserInfoCurrentEntriesKey': userInfoEntries}

# Makes our changes to apply immediately on running processes.
# It's undocumented but this is the notification that the prefpane
# sends out when you make changes.