Search code examples
linuxcronraspberry-pigoogle-assistant-sdk

Run Google Assistant SDK on boot (Raspbian)


I am currently trying to get a cron job working, so that the google assistant starts automatically after boot. For that I created this cron job which executes on reboot.

SHELL=/bin/sh PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

@Reboot lxterminal -t "Google Assistant" -e /bin/bash /home/pi/Desktop/init.sh

lxterminal will open a window with google assistant running within. Here is my full cron job:

#!/bin/bash
            
SHELL=/bin/sh
PATH=/usr/bin:/bin:/home/pi/Desktop:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin     


source /home/pi/env/bin/activate
          
python3 /home/pi/assistant-sdk-python/google-assistant-sdk/googlesamples/assistant/grpc/pushtotalk.py

I already tried answers from similar problems and even specified the path variable for cron, but it still won't work for me. The script isn't the fault, when I execute it manually it runs fine.


Solution

  • The problem wasn't with cron, though I settled for using a systemd service instead. What I didn't know was, that Lxterminal needed a initalized screen to work and due to the script running on boot it wasn't. This is an easy fix. Either add an delay of 30 Seconds or other values, depending on your system, to the beginning of your script or simulate the display beeing initalized already with export DISPLAY=:1