def lock():
    cmd = '/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend'
    call = __salt__['cmd.run_all'](
        cmd,
        output_loglevel='debug',
        python_shell=False
    )
    _check_cmd(call)

    return True
Lock the desktop session
dataset/ETHPy150Open saltstack/salt/salt/modules/mac_desktop.py/lock