Old 09-29-2019, 02:22 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,648
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:
Code:
#!/usr/bin/env python

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

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.

edit:

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

thanks,
babag

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
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 1,648
Default

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:
Code:
#!/bin/sh

cd /home/babag/opt/REAPER/

sudo ./keyboard_macro2.py &

./reaper

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.

thanks,
babag
babag is offline   Reply With Quote
Reply

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 02:17 AM.


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