def _in(): default_mind = 'boot' load_minds() set_mind(default_mind) logging.debug('"{}" is now listening. Say "Boot Mind!" to see if it can hear you.'.format(default_mind)) while not oa.core.finished.is_set(): text = get() logging.debug('Input: {}'.format(text)) mind = oa.core.mind if (text is None) or (text.strip() == ''): # Nothing to do. continue t = text.upper() # Check for a matching command. fn = mind.kws.get(t, None) if fn is not None: # There are two types of commands, stubs and command line text. # For stubs, call `perform()`. if isCallable(fn): call_function(fn) oa.last_command = t # For strings, call `sys_exec()`. elif isinstance(fn, str): sys_exec(fn) oa.last_command = t else: # Any unknown command raises an exception. raise Exception("Unable to process: {}".format(text)) yield text
def volume(move=2): """ Change volume level. Positive `move`: Volume Up Negative `move`: Volume Down """ if oa.sys.os == 'win': # Up by 2. if move > 0: # Volume up. key = chr(175) else: move = -move key = chr(174) while move > 0: wshell.SendKeys(key) move -= 2 elif oa.sys.os in ('linux', 'mac'): if move > 0: sys_exec('pamixer --increase %d' % move) else: sys_exec('pamixer --decrease %d' % (-move)) else: info('Unknown operating system.')
def mute(mute=True): """ Mute or unmute speakers. """ if oa.legacy.sys.os == 'win': wshell.SendKeys(chr(173)) elif oa.legacy.sys.os in ('linux', 'mac'): sys_exec('amixer set Master %smute' % (((not mute) and 'un') or '')) else: info('Unknown operating system.')
def volume(move=2): """ Change volume level. Positive `move`: Volume Up Negative `move`: Volume Down """ if move > 0: sys_exec('amixer set Master' % move) else: sys_exec('amixer set Master' % (-move))