I've spent most of the day trying to launch two commands after login of the GUI on Raspberry OS. I am trying to run a Ruby on Rails server after logging into the GUI (not on boot). The commands I would like to run are:
#!/bin/bash . /home/pi/.rvm/scripts/rvm cd /home/pi/base/ && rails s -b 10.3.141.1 -p 3000 -d &
I have been trying to do this using
.xinitrc but it's proving impossible and I haven't got further than breaking my installation. I've also had a go at the
autostart options and followed various articles and Q&As online. Also tried saving it into a separate script and running that, they all work as I expect from the command line when triggered but the server isn't running automatically after GUI login. The closest I've got is the server running automatically once I start a shell from within the GUI.
I think I should be editing the
xsession files as these are run by
lightdm after logging in via the GUI? But when I do the GUI breaks and just returns me to the login password screen after each attempt.
Despite a lot of time, I don't seem much closer to the solution - from experience this normally means I've misunderstood something fundamental!
Any help would be amazing