Пример #1
0
def sinkSetMute(value):
    """
    设置是否静音
    :return:None
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.SetMute(dbus.Boolean(value))
Пример #2
0
def getEdgeMoveStopDuration():
    """
    获取触控屏边缘划入后停留时间
    :return:dbus.UInt32
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    result = property_obj.GetEdgeMoveStopDuration()
    return result
Пример #3
0
def sinkSetFade(value):
    """
    设置前后声道平衡值
    :return:None
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.SetFade(dbus.Double(value))
Пример #4
0
def getLongPressDuration():
    """
    获取触控屏长按超时时间
    :return:dbus.UInt32
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    result = property_obj.GetLongPressDuration()
    return result
Пример #5
0
def setEdgeMoveStopDuration(duration):
    """
    设置触控屏边缘划入后停留时间
    :param duration:超时时间
    :return:None
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    logging.info(f'设置触控屏边缘划入后停留时间为{duration}')
    property_obj.SetEdgeMoveStopDuration(duration)
Пример #6
0
def getDefaultSourcePath():
    """
    获取默认Source路径
    :return:Source路径
    """
    property_obj = sessionCommon.session_bus(dbus_name='com.deepin.daemon.Audio', dbus_path='/com/deepin/daemon/Audio',
                                             iface_name='org.freedesktop.DBus.Properties')
    source_path = property_obj.Get('com.deepin.daemon.Audio', 'DefaultSource')
    return source_path
Пример #7
0
def noRestartPulseAudio():
    """
    用于设置不自动重启 pulseaudio 服务
    :return:True
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.NoRestartPulseAudio()
    logging.info("检查接口执行成功")
    return True
Пример #8
0
def search(app_id: str = 'dde-file-manager'):
    """
    Search (String key) ↦ ():开始菜单中搜索应用程序
    :param app_id:被搜索的关键字,默认搜索文件管理器
    :return:True or False
    """
    logging.info(f'开始菜单中搜索应用程序{app_id}')
    property_obj = sessionCommon.session_bus(DBUS_NAMEN, DBUS_PATH, IFACE_NAME)
    property_obj.Search(dbus.String(app_id))
Пример #9
0
def reset():
    """
    用于重置输入输出设备的音量以及sound-effect的开关.
    :return:True
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.Reset()
    logging.info("检查接口执行成功")
    return True
Пример #10
0
def setLongPressDuration(duration):
    """
    设置触控屏长按超时时间
    :param duration:超时时间
    :return:None
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    logging.info(f'设置触控屏长按超时时间为{duration}')
    property_obj.SetLongPressDuration(duration)
Пример #11
0
def getFade():
    """
    前后声道平衡值
    :return:dbus.Double
    """
    dbus_path = getDefaultSourcePath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path=dbus_path,
                                             iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Audio.Source', 'Fade')
    return result
Пример #12
0
def sourceSetBalance(value, isPlay):
    """
    设置左右声道平衡
    :param value:声道平衡值
    :param isPlay:是否播放声音反馈
    :return:None
    """
    dbus_path = getDefaultSourcePath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.SetBalance(dbus.Double(value), dbus.Boolean(isPlay))
Пример #13
0
def getMute():
    """
    获取是否静音值
    :return:dbus.Boolean
    """
    dbus_path = getDefaultSourcePath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path=dbus_path,
                                             iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Audio.Source', 'Mute')
    return result
Пример #14
0
def getNumLockStateNumber():
    """
    获取NumLock的状态,返回状态值
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(
        DBUS_NAME, DBUS_PATH, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Keybinding', 'NumLockState')
    logging.info(result)
    return result
Пример #15
0
def sinkSetVolume(value, isPlay):
    """
    设置音量大小
    :param value:音量大小
    :param isPlay:是否播放声音反馈
    :return:None
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.SetVolume(dbus.Double(value), dbus.Boolean(isPlay))
Пример #16
0
def setUseProxy(app_id: str = 'dde-file-manager', value: bool = False):
    """
    SetUseProxy (String id, Boolean value) ↦ ():设置指定id的程序是否使用代理
    :param app_id:应程序的id,可以使用GetAllItemInfos接口获得,默认检查文件管理器
    :param value:是否使用代理
    :return:True or False
    """
    logging.info(f'设置{app_id}是否使用代理,设置值为{value}')
    property_obj = sessionCommon.session_bus(DBUS_NAMEN, DBUS_PATH, IFACE_NAME)
    property_obj.SetUseProxy(dbus.String(app_id), dbus.Boolean(value))
Пример #17
0
def setDisableScaling(app_id: str = 'dde-file-manager', value: bool = False) -> bool:
    """
    SetDisableScaling (string id, bool value) :设置指定id的程序是否禁用缩放
    :param app_id:应程序的id,可以使用GetAllItemInfos接口获得,默认检查文件管理器
    :param value:是否禁用缩放
    :return: True or False
    """
    property_obj = sessionCommon.session_bus(DBUS_NAMEN, DBUS_PATH, IFACE_NAME)
    property_obj.SetDisableScaling(dbus.String(app_id), dbus.Boolean(value))
    return getDisableScaling(app_id=app_id, target=value)
Пример #18
0
def sinkSetPort(name):
    """
    设置此设备的当前使用端口
    :param name:此设备的当前使用端口
    :return:True or False
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    property_obj.SetPort(name)
    logging.info("设置此设备的当前使用端口")
    return True
Пример #19
0
def isPortEnabled(cardId, portName):
    """
    获取音频端口的启用/禁用状态
    :param cardId:声卡 id
    :param portName:端口名
    :return:result
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    result = property_obj.IsPortEnabled(cardId, portName)
    logging.info(result)
    return result
Пример #20
0
def is_in_apps(app_id: str = 'dde-file-manager'):
    property_obj = sessionCommon.session_bus(DBUS_NAMEN, DBUS_PATH, IFACE_NAME)
    all_item_info = property_obj.GetAllItemInfos()
    logging.info(f'{"=" * 20}系统和当前用户所有应用程序的信息{"=" * 20}')
    for struct in all_item_info:
        if struct[2] == dbus.String(app_id):
            logging.info(f'{app_id}在应用程序列表中')
            return True
    else:
        logging.info(f'{app_id}不在在应用程序列表中')
        return False
Пример #21
0
def getVolume():
    """
    获取音量大小
    :return:dbus.Double
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(
        dbus_name,
        dbus_path=dbus_path,
        iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Audio.Sink', 'Volume')
    return result
Пример #22
0
def getInfos():
    """
    获取手势信息
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name='org.freedesktop.DBus.Properties')
    ret = property_obj.Get('com.deepin.daemon.Gesture', 'Infos')
    if isinstance(ret, dbus.Array):
        logging.info("获取手势信息成功")
        return True
    else:
        logging.info("获取手势信息失败")
        return False
Пример #23
0
def getCurrentLocale():
    """
    获取当前用户的桌面语言环境
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(DBUS_NAME, DBUS_PATH, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.LangSelector', 'CurrentLocale')
    logging.info(result)
    if isinstance(result, dbus.String):
        logging.info("获取当前用户的桌面语言环境成功")
        return True
    else:
        logging.info("获取当前用户的桌面语言环境失败")
        return False
Пример #24
0
def getLocaleState():
    """
    获取存储当前语言环境的状态  0:语言环境切换完成  1:语言环境正在切换中
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(DBUS_NAME, DBUS_PATH, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.LangSelector', 'LocaleState')
    logging.info(result)
    if isinstance(result, dbus.Int32):
        logging.info("获取存储当前语言环境的状态成功")
        return True
    else:
        logging.info("获取存储当前语言环境的状态失败")
        return False
Пример #25
0
def getLocales():
    """
    获取当前语言环境列表的内容
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(DBUS_NAME, DBUS_PATH, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.LangSelector', 'Locales')
    logging.info(result)
    if isinstance(result, dbus.Array):
        logging.info("获取当前语言环境列表的内容成功")
        return True
    else:
        logging.info(f'返回数据不是Array:{type(result)}')
        return False
Пример #26
0
def getRealDisplayMode():
    """
    获取显示器真实排列方式
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    dbus_out = property_obj.GetRealDisplayMode()
    logging.info(dbus_out)
    if dbus_out:
        logging.info('获取显示器真实排列方式成功')
        return True
    else:
        logging.info('获取显示器真实排列方式失败')
        return False
Пример #27
0
def getDefaultSource():
    """
    默认 Source 对象的路径
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(
        dbus_name, dbus_path, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Audio', 'DefaultSource')
    logging.info(type(result))
    if isinstance(result, dbus.ObjectPath):
        logging.info(f'读取DefaultSource属性值{result}成功')
        return True
    else:
        logging.info("读取DefaultSource属性值失败")
        return False
Пример #28
0
def sinkGetMeter():
    """
    返回 Meter 对象的 path,目前该方法具体逻辑未实现
    :return:True or False
    """
    dbus_path = getDefaultSinkPath()
    property_obj = sessionCommon.session_bus(dbus_name, dbus_path, iface_name)
    result = property_obj.GetMeter()
    logging.info(result)
    if isinstance(result, dbus.ObjectPath):
        logging.info("返回Meter对象的path成功")
        return True
    else:
        logging.info("读取Meter对象的path失败")
        return False
Пример #29
0
def getReduceNoise():
    """
    是否打开降噪开关,如果打开,将调用webrtc为物理设备建立虚拟通道,达到降噪效果,关闭则声音效果和原来一致
    :return:True or False
    """
    property_obj = sessionCommon.session_bus(
        dbus_name, dbus_path, iface_name='org.freedesktop.DBus.Properties')
    result = property_obj.Get('com.deepin.daemon.Audio', 'ReduceNoise')
    logging.info(result)
    if isinstance(result, dbus.Boolean):
        logging.info("获取降噪开关状态成功")
        return True
    else:
        logging.info("获取降噪开关状态失败")
        return False
Пример #30
0
def getUseProxy(app_id: str = 'dde-file-manager') -> bool:
    """
    GetUseProxy (string id) -> (bool value):获取id对应的程序是否使用代理,true表示使用代理,false表示不使用
    :param app_id:应程序的id,可以使用GetAllItemInfos接口获得,默认检查文件管理器
    :return:True or False
    """
    logging.info(f'检查{app_id}是否能使用代理')
    property_obj = sessionCommon.session_bus(DBUS_NAMEN, DBUS_PATH, IFACE_NAME)
    is_use_proxy = property_obj.GetUseProxy(dbus.String(app_id))
    if isinstance(is_use_proxy, dbus.Boolean):
        logging.info(f'is_use_proxy: {is_use_proxy},结果符合预期')
        return True
    else:
        logging.info(f'返回的数据类型有误,type:{type(is_use_proxy)}')
        return False