Beispiel #1
0
def _get_type(name, attribute, user):
    cmd = ['gsettings', 'range', name.replace('/', '.'), attribute]
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid)
    if proc.returncode == 0:
        return data
    else:
        return None
Beispiel #2
0
def read(name, attribute, user=None):
    cmd = ['dconf', 'read', '/{}/{}'.format(name, attribute)]
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid)
    if proc.returncode == 0:
        data = gvariant.loads(data, None)
        return data
    else:
        raise salt.exceptions.CommandExecutionError()
Beispiel #3
0
def read(name, attribute, user=None):
    cmd = ['gsettings', 'get', name.replace('/', '.'), attribute]
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid)
    if proc.returncode == 0:
        data = gvariant.loads(data, _get_type(name, attribute, user))
        return data
    else:
        raise salt.exceptions.CommandExecutionError()
Beispiel #4
0
def write(name, attribute, value, user=None):
    formatted = gvariant.dumps(value)
    cmd = ['dconf', 'write', '/{}/{}'.format(name, attribute), formatted]
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid)
    if proc.returncode == 0:
        return formatted
    else:
        print(cmd)
    raise salt.exceptions.CommandExecutionError()
Beispiel #5
0
def write(name, attribute, value, user=None):
    formatted = gvariant.dumps(value)
    cmd = ['gsettings', 'set', name.replace('/', '.'), attribute, formatted]
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid)
    if proc.returncode == 0:
        return formatted
    raise salt.exceptions.CommandExecutionError(
        "Writing {}/{} exited with return code {}.".format(
            name, attribute, proc.returncode))
Beispiel #6
0
def create(name, attribute, value, user=None):
    formatted = gvariant.dumps(value)
    cmd = ['dconf', 'load', '/{}/'.format(name)]
    stdin = '[/]\n{}={}\n'.format(attribute, formatted)
    uid, gid, home = _user_settings(user)
    proc, data = process.run_as_user(cmd, uid, stdin=stdin)
    if proc.returncode == 0:
        return formatted
    else:
        pass
    raise salt.exceptions.CommandExecutionError()