How to connect shape key animation as driver to rotate a bone in pose mode I am attempting to utilize facecap (iphone app) face fbx file (it has 51 shape keys with animation data on it etc) on a character with rigify rig (face as well).

Question.
i want jaw rotation (jaw controller x rotation) to take animation data (driven) by head object shapekeys['jawOpen'].
any ideas or python psudo code to setup driver expression will really help. thanks in advance
i managed to write one. if anyone else looking for same thing, below is simple function to test and could be starting point. 
select facecap head mesh and rigify jaw master (in pose mode)

def bindFacecapToRigify():
    obj = bpy.context.selected_objects[0]
    sk = obj.data.shape_keys
    # driver details (skname:'pbone','prop','axis','dir'),
    skname = 'jawOpen'
    pbone = bpy.context.active_pose_bone
    d = pbone.driver_add("rotation_euler",0)
    d.driver.type = "AVERAGE"
    var = d.driver.variables.new()
    var.targets[0].id_type="KEY"
    var.targets[0].id= sk
    data_path = "key_blocks[\""+sk.key_blocks[2].name+"\"].value"
    data_path = "key_blocks[\""+"jawOpen"+"\"].value"
    var.targets[0].data_path = data_path
    d.driver.expression = "var"