Page 1 of 1

Pykeyboard to activate Push-to-Talk in Mumble

Posted: Sun Mar 02, 2014 8:58 am
by nickeh
Hi,

I'm trying to control different Mumble shortcuts (PTT, Volume up/down etc) from GPIO switches, I have CRTL_L+1 to activate Push-to-Talk but nothing happens with the code below. If I change it to send ALT+o it opens the Configure menu so it targets the right window but does not activate Mumble user set shortcuts.

Code: Select all

import subprocess, os, time, pykeyboard

os.environ['DISPLAY'] = ':0.0'
subprocess.Popen('XAUTHORITY=/home/pi/.Xauthority DISPLAY=:0 /usr/bin/xdotool search --onlyvisible --name Mumble windowactivate', shell=True)

k = pykeyboard.PyKeyboard()
k.press_key(k.control_l_key)
k.press_key('1')
time.sleep(2)
k.release_key('1')
k.release_key(k.control_l_key)
Any ideas on what I could try next?

Re: Pykeyboard to activate Push-to-Talk in Mumble

Posted: Tue Mar 04, 2014 7:44 am
by nickeh
I have now captured what is being pressed with XEV, the first output is using the local usb keyboard:

Code: Select all

KeyPress event, serial 43, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2316237, (60,244), root:(1340,644),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2316557, (60,244), root:(1340,644),
    state 0x4, keycode 10 (keysym 0x31, 1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2316677, (60,244), root:(1340,644),
    state 0x4, keycode 10 (keysym 0x31, 1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2316965, (60,244), root:(1340,644),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
and here is the output from the python script above (sleep changed)

Code: Select all

KeyPress event, serial 43, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2370975, (60,244), root:(1340,644),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2371015, (60,244), root:(1340,644),
    state 0x4, keycode 10 (keysym 0x31, 1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XmbLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2371133, (60,244), root:(1340,644),
    state 0x4, keycode 10 (keysym 0x31, 1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

KeyRelease event, serial 46, synthetic NO, window 0x1600001,
    root 0x43, subw 0x0, time 2371139, (60,244), root:(1340,644),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
They both match and should execute the CTRL + 1 shortcut. I also learned that if I run the same code on another computer (Ubuntu 13.10) it works perfectly. So the problem seems to be related to the RPi version of the Mumble client or the RPi in general.

If anybody has any ideas, I would be grateful to hear them.