Search code examples
linuxraspbian

Linux (Raspbian) - Running script at login(auto) and keeping window in foreground for interaction


I have tried everything to make this work. login scripts, LXDE-pi autostart, cron task @reboot, init.d, and I cannot get my script running with a terminal window running in the foreground so that I can interact with it. I can get it to run but only in background. Is there any way I can get a script that simply runs: "python /home/pi/myscript.py" at startup and leaves the terminal window open with the script running for my keyboard inputs? I would rather not use the /dev/input/event if at all possible. Thanks


Solution

  • I was missing a simple flag.. what I did was edit ~/.config/lxsession/LXDE-pi/autostart with

    @lxterminal -e /home/pi/autoscript.sh
    

    and in that file, I added

    cd /home/pi/
    python -i 2Trackmain.py
    

    I wasn't using the -i flag, so every time I pressed Enter to move through the interactive py script, it exited the terminal, using -i will keep the window open for your interaction. And I only had to add the change directory part b/c the script called other scripts in the same directory.