boutch55555
Joined: 01 Mar 2008 Posts: 1
Digg It |
Posted: Sat Mar 01, 2008 6:38 pm Post subject: BASH commands with WMD |
|
|
For those who might be interested in running BASH commands from WMD (0.1.2), I just spent a couple of hours finding a *working* solution. Right now, i'm using it to control xmms through xmms-shell.
how it's done :
first I edited CommandMapper.py
1 : after
from wmd.EventBridges.uinputKeymap import * (line 3)
I added
import os
2 : add bash to the valid commands (line 9)
valid_commands = [ 'quit', 'key', 'click', 'WMDPower', 'bash' ]
3 : add a new def for the bash event (i did it between do_key & do_click)(around line 44)
def do_bash( self, state, parms ):
keyss = parms
self.os.system( state, keyss )
4 : save
5 : edit Config.py to add your custom BASH commands
example :
'A': ['bash', '/usr/local/bin/xmms-shell -e play &' ], # A key: xmms play
'L': ['bash', '/usr/local/bin/xmms-shell -e previous &' ], # prev
'R': ['bash', '/usr/local/bin/xmms-shell -e next &'] # next
i had to do two small scripts to control the incremental volume. they stored in /usr/bin/ and named volup & voldown
here is volup :
#!/bin/bash
x=`xmms-shell -e status |grep Left |tail -c3`
z=$(($x + 5))
xmms-shell -e "volume $z"
then just call them from Config.py, same as before :
'+': ['bash', '/usr/bin/volup &' ], # volup
'-': ['bash', '/usr/bin/voldown &' ], # voldown
et voila !
note : it may not be the best way to do it(I aint a programmer) but at least it works
have fun
Boutch |
|