• python dbus note


    ..

    python dbus 设置

    import dbus
    bus = dbus.SessionBus()
    //参数为prog 和path
    obj = bus.get_object('com.deepin.wm','/com/deepin/wm')
    //参数为interface
    intf = dbus.Interface(obj,'org.freedesktop.DBus.Properties')
    //参数为方法
    meth = intf.get_dbus_method('Set')
    meth(dbus.String('com.deepin.wm'),dbus.String('compositingEnabled'),dbus.Boolean(True, variant_level=1))

    ..占位

     1 #Method
     2 def mothodAddUserLayout():
     3     progname = 'com.deepin.daemon.InputDevices'
     4     objpath = '/com/deepin/daemon/InputDevice/Keyboard'
     5     intfname = 'com.deepin.daemon.InputDevice.Keyboard'
     6     methname = 'AddUserLayout'
     7 
     8     bus = dbus.SessionBus()
     9     obj = bus.get_object(progname, objpath)  # Here we get object
    10     intf = dbus.Interface(obj, intfname)      # Here we get interface
    11     meth = intf.get_dbus_method(methname)      # Here we get method
    12     #参数
    13     meth("cn;altgr-pinyin")
    14 
    15 #propties GetAll
    16 def propGetAll():
    17     progname = 'com.deepin.daemon.InputDevices'
    18     objpath = '/com/deepin/daemon/InputDevice/Keyboard'
    19     intfname = 'org.freedesktop.DBus.Properties'
    20     methname = 'GetAll'
    21 
    22     bus = dbus.SessionBus()
    23     obj = bus.get_object(progname, objpath)  # Here we get object
    24     intf = dbus.Interface(obj, intfname)      # Here we get interface
    25     meth = intf.get_dbus_method(methname)      # Here we get method
    26     # print(meth)
    27     # print(meth())
    28     v = meth("com.deepin.daemon.InputDevice.Keyboard")
    29     # v 是字典
    30     layout_arr = v["UserLayoutList"]
    31     # for x in v:
    32     #     print(x)
    33 
    34     return layout_arr

  • 相关阅读:
    解决百度网盘倍速需要会员问题
    npm run dev其实就是vue-cli-service serve
    git常见操作和git原理
    ajax promise三种状态
    ajax get请求
    vue2.0x methods中一个函数调用另外一个函数
    Web前端开发规范之文件存储位置规范
    大数据应用期末总评
    分布式文件系统HDFS 练习
    安装Hadoop
  • 原文地址:https://www.cnblogs.com/eiguleo/p/14437185.html
Copyright © 2020-2023  润新知