def get_current_volume(type='output'): cmd = 'get volume settings' settings = myosascript.run(cmd) # assert len(settings) == 1, "Wrong output: %s" % cmd # assert type(settings[0]) == str, "Wrong type of: %s" % settings[0] # assert len(settings[0].split(', ')) == 4, "Wrong format of: %s" % settings[0].split(', ') # assert len(settings[0].split(', ')[0].split(':')) == 2, "Wrong format of: %s" % settings[0].split(', ')[0] # assert type(settings[0].split(', ')[0].split(':')[1]) == str, "Wrong type of: %s" % settings[0].split(', ')[0].split(':')[1] return int( settings[0].split(', ')[0].split(':')[1]) if type == 'output' else int( settings[0].split(', ')[1].split(':')[1]) if type == 'input' else 0
def press_space(): myosascript.run(TMPL_K % '49')
def press_esc(): myosascript.run(TMPL_K % '53')
def brightness_down(): myosascript.run(TMPL_K_U % ('107', 'function down'))
def brightness_up(): myosascript.run(TMPL_K_U % ('113', 'function down'))
def keystroke_return(): myosascript.run(TMPL_KS % 'return')
def keystroke(val): myosascript.run(TMPL_KS % '"' + val + '"')
def press_return(): myosascript.run(TMPL_K % '36')
def press_enter(): myosascript.run(TMPL_K % '76')
def press_right(): myosascript.run(TMPL_K % '124')
def press_left(): myosascript.run(TMPL_K % '123')
def press_up(): myosascript.run(TMPL_K % '126')
def press_down(): myosascript.run(TMPL_K % '125')
def press_delete(): myosascript.run(TMPL_K % '51')
def unlock(): myosascript.run(TMPL % 'click at {0, 0}') myosascript.run(TMPL_KS % '2002') myosascript.run(TMPL_K % '76')
def set_input_volume(val): myosascript.run('set volume input volume %s' % val)