0

Here's the story (TL;DR is at the bottom): I've followed the tutorials in the github page and pimylifeup for setting up Alexa on a RPi3. I now have a working Alexa, started with a nice script. Great success!! However, the script opens 3 lxterminal windows and one java window. That's a lot of wasted real estate! So I thought I would use Screen to try and optimize that. I am able to have Alexa working if I execute the 3 scripts inside screen, manually. What I am having issues is with is running a script which automatically sends those commands to screen sessions (having them in a single session, and different shells will be the next step).

TL;DR: Here's what I have:

Starting the wake word detection in a bash script:

pi@pi3:~/shared/Alexa $ cat startAlexainscreen.sh
#!/bin/bash
screen -dmS "test"
#screen -S "test" -p 0 -X exec sh ~/shared/Alexa/3-WakeWord.sh
screen -S "test" -p 0 -X exec ~/alexa-avs-sample-app/sample/wakeWordAgent/src/wakeWordAgent -e sensory

checking inside screen "test" after executing the above script:

Cannot exec '/home/pi/alexa-avs-sample-app/sample/wakeWordAgent/src/wakeWordAgent': No such file or directory
pi@pi3:~/shared/Alexa $

So it seems it doesn't run the command and it's not taking into account the parameters either. I'm sure I'm missing something terribly basic.

So I tried to put the command inside a bash script:

pi@pi3:~/shared/Alexa $ cat 3-WakeWord.sh
#!/bin/bash
/home/pi/alexa-avs-sample-app/samples/wakeWordAgent/src/wakeWordAgent -e sensory
pi@pi3:~/shared/Alexa $ sh 3-WakeWord.sh
Usage: WakeWordAgent -e <engine_type>
 engine_type options:
 'kitt_ai'
 'sensory'
 'gpio'
WakeWordAgent [-h] [--help]
 prints help (this message)

Seems to run the command, but doesn't take into account the parameters. I've tried escaping the spaces, adding quotation marks, etc...

Thanks for the insights.

As a final result I expect to be able to start the 3 scripts inside a single screen session. Here are the other 2 scripts:

pi@pi3:~/shared/Alexa $ cat 1-npm.sh
#!/bin/bash
cd ~/alexa-avs-sample-app/samples/companionService
npm start

pi@pi3:~/shared/Alexa $ cat 2-JVM.sh
#!/bin/bash
cd ~/alexa-avs-sample-app/samples/javaclient
export $DISPLAY=:0.0
mvn exec:exec

Note that starting the commands in scripts 1, 2 and 3 manually inside screen, works perfectly. For some reason, calling these commands inside scripts, fails.

4
  • I think my problem is with scripting, not with Screen...
    – Mike
    Sep 8, 2017 at 9:45
  • ... The desktop environment has virtual desktops, so you have unlimited real estate, just start it on one and switch back to where you were working. If you are not sure what I am talking about see: raspberrypi.stackexchange.com/questions/30056/…
    – crasic
    Sep 8, 2017 at 14:50
  • Thanks for the workaround. I'd still like to get unstuck, though.
    – Mike
    Sep 8, 2017 at 16:53
  • In your post you have both wakeWordAgent and WakeWordAgent, which one is it? 3-WakeWord.sh specifies /bin/bash as interpreter, yet you start it with exec sh, any reason why you did this? And finally, what's the problem with the "desktop real estate"? You know you can minimize windows, right? Feb 12, 2020 at 12:41

1 Answer 1

1

You can script some sessions in a screen with the -c option:

screen -dmS test -c screen_script

“screen_script” example contents:

screen ~/shared/Alexa/3-WakeWord.sh
screen ~/alexa-avs-sample-app/sample/wakeWordAgent/src/wakeWordAgent -e sensory
# and so on…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.