Working actions

This commit is contained in:
Denis Zheleztsov 2015-07-22 14:24:47 +03:00
parent c538750f3e
commit 92d5504f0c

View File

@ -23,12 +23,16 @@ def do():
if action['position'] != 'middle':
if action['corner'] == 'top' or action['corner'] == 'bottom':
if position['y'] == corners[ action['corner'] ] and position['x'] == corners[action['position']]:
msg = type_exec(action)
notify(msg)
print action
print position
print 'Get position: {0} and corner {1}'.format(action['position'], action['corner'])
sleep(1)
elif action['corner'] == 'left' or action['corner'] == 'right':
if position['x'] == corners[ action['position'] ] and position['y'] == corners[ action['corner'] ]:
msg = type_exec(action)
notify(msg)
print action
print position
print 'Get position: {0} and corner {1}'.format(action['position'], action['corner'])
@ -38,19 +42,32 @@ def do():
elif action['position'] == 'middle':
if action['corner'] == 'top' or action['corner'] == 'bottom':
if position['y'] == corners[ action['corner'] ] and position['x'] > config['corners']['middle_x_start'] and position['x'] < config['corners']['middle_x_end']:
msg = type_exec(action)
notify(msg)
print action
print position
print 'Get position: {0} and corner {1}'.format(action['position'], action['corner'])
sleep(1)
elif action['corner'] == 'left' or action['corner'] == 'right':
if position['x'] == corners[ action['corner'] ] and position['y'] > config['corners']['middle_y_start'] and position['y'] < config['corners']['middle_y_end']:
msg = type_exec(action)
notify(msg)
print action
print position
print 'Get position: {0} and corner {1}'.format(action['position'], action['corner'])
sleep(1)
#
# Detect type and execute
def type_exec(action):
if action['type'] == 'notify':
out = get_cmd(action['command'])
return out
elif action['type'] == 'exec':
get_cmd(action['command'])
return action['command']
else:
return 'Unknown type!'
# Get shell command output
@ -62,4 +79,5 @@ def get_cmd(cmd):
# Show notify message
def notify(msg):
get_cmd( "notify-send 'azot event' '{0}'".format(msg) )