Old 09-29-2019, 02:22 PM   #1
Human being with feelings
Join Date: Nov 2009
Posts: 1,720
Default scripting a macro from the os?

not sure if this goes here or in the scripting forum but i'm on linux and these are linux tools so...

i'm trying to set up an extra keyboard to send macros to reaper. i have this python script as a test:
#!/usr/bin/env python

import os
from evdev import InputDevice, categorize, ecodes
dev = InputDevice('/dev/input/event12')

for event in dev.read_loop():
  if event.type == ecodes.EV_KEY:
    key = categorize(event)
    if key.keystate == key.key_down:
        if key.keycode == 'KEY_ESC':
            os.system('xdotool key v')
my second keyboard is event12. this code just tries to toggle the volume envelope. it assumes the timeline window is focused. when i run it, though, reaper reports the project as [modified] in the main screen title bar but the volume envelope never becomes visible. same thing with p for pan envelope. there's a greater than 99% probability that i'm doing something wrong but, just in case, is this me or does reaper have an issue with doing this? can anyone get this code to work? tested with reaper64/5979+dev0625 and kubuntu/kxstudio.


just tried it with
xdotool search --class REAPER windowactivate --sync %1 key v windowactivate $(xdotool getactivewindow)
xdotool key v
same result.


Last edited by babag; 09-29-2019 at 02:48 PM.
babag is offline   Reply With Quote
Old 09-29-2019, 09:43 PM   #2
Human being with feelings
Join Date: Nov 2009
Posts: 1,720

well, seemingly inexplicably, it works now. using the first code posted. i do have another question about this, though.

once it started working, i wanted to tie it to starting reaper. for now, i want to use this second keyboard exclusively with reaper. therefore, i wanted to have the script start with reaper and close when reaper does. this simple bash script does that but, i'm guessing, the linux users here know a more elegant way to accomplish this.

what i've done is to make a simple script that, first, starts the script, keeping it running in the background and, second, starts reaper. finally, when reaper is closed, it kills the script.

is there a better way to do this? here's the script:

cd /home/babag/opt/REAPER/

sudo ./keyboard_macro2.py &


sudo pkill -f keyboard_macro2.py
lastly, i put the script into a desktop icon so clicking it activates the second keyboard and starts reaper.

babag is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 11:59 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.