plasticus wrote:I didn't try this before as I don't actually need the GUI (but I guess I'm confused about what this means). However, following
this tutorial, I don't have the file
/root/.config/lxsession/LXDE-pi/autostart and I need root permissions as the python script will use GPIO. I do have
/home/pi/.config/lxsession/LXDE-pi/autostart but the tutorial says that this is not for the root user
(running the GUI with "sudo startx")
It appears you do not need root permissions to use GPIO, as your manually-run scenario shows
no associated processes running as root (unless the MindTheChair process needs root, and was running, and wasn't in the ps output you provided - also, I
think the need for root permission to access GPIO pins was removed in the last year or so). By GUI, I mean X11 / X-Windows. PureData is going out of its way to use
wish, the "Simple
windowing
shell" for Tcl/Tk (Tk being a graphical toolkit on top of Tcl); I am presuming this is necessary to how it functions. Thus, your script, by virtue of being implemented in PureData, requires X11, whether you want to display anything or not.
So, you don't want to modify root's X11 startup, you want to modify user pi's startup, and
/home/pi/.config/lxsession/LXDE-pi/autostart is where you want to do that (if the file didn't exist, you could create it, and LXDE will read it on startup).
plasticus wrote:it's included in my startup script. it's another software that I need to run on startup
Ah, okay. FWIW, MindTheChair doesn't appear to be running in your manually-run scenario (unless those lines were outside the bit you posted).
plasticus wrote:ok, my script is
Code: Select all
sudo puredata /home/pi/puredata/MindTheChair/audio.pd &
sudo python /home/pi/python/Mindwave/test1.py
And (
to get the processes running without a bunch of sudo processes hanging around), you'd want to remove the "sudo" from the front of each line, and execute
that script with
sudo scriptname - the script will run with elevated (root) permissions, it will launch two processes into the background, both running as root, and then your startup script ("scriptname", above) will finish and the single sudo process will finish, and those two launched processes (and their descendents) will still be running as root.
plasticus wrote:ok so I can change the script like this, right?
Code: Select all
puredata /home/pi/puredata/MindTheChair/audio.pd &
python /home/pi/python/Mindwave/test1.py
Yes, it would appear so. And in the case of the Mindwave script (at least), if you have "
#!/usr/bin/env python" as the first line, and set the execute bit on the script (once) with "
chmod a+x /home/pi/python/Mindwave/test1.py", then you don't need to say "python" in front of it, you can run it as a "first class citizen" on the system (that specially crafted first line tells the kernel how to go about executing the script, and the execute bit in the script's permissions tell the kernel that the file is something it
can try to execute).
I hope I don't sound too abrupt, in all of this. I apologize if I come across that way. I don't mean to be. Just trying to get a lot of details across in a hurry.