Charrua 115 Posted April 10, 2019 Share Posted April 10, 2019 Hi, it's been a long time from my last post here I'm finishing a Leadwerks program on ubuntu 16.04, not a game, is a 3d graphical interface for a "Shoot simulator" with real (modified) guns. I'm so novice with linux, so after some reading i got the application run at startup. This application is the only one which will run on this pc, so it should start at startup and the system should shootdown when quitting from the application. (after try and pray many times... ) Basically i end placing a .desktop file in .config\autostart directory with a exec command to the leadwerks script to run the project file, so simple once one get to know how I guess that, i can place a shootdown command on the launch script, but I did not find the way, all my readings point to: shootdown -h now (edit: i mean.. shutdown not shootdown) but, i guess i'm not doing, writting, placing it in the correct way. Some linux expert here? Thank's in advance Juan Quote Link to post Share on other sites
aiaf 226 Posted April 11, 2019 Share Posted April 11, 2019 Create a run.sh: #!/bin/bash exec your app here shutdown -h now Make it executable chmod a+x run.sh. And your done. Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 thanks for answer i have this file in .config/autostart Quote [Desktop Entry] Encoding=UTF-8 Name=Simulador1 Comment=Launch DirSyncPro Exec=gnome-terminal -e /home/juan/Documents/Leadwerks/Projects/pj01/pj01.sh Icon=/usr/share/icons/HighContrast/32x32/apps/gnomine.png Type=Application also works with: Quote [Desktop Entry] Encoding=UTF-8 Name=Simulador2 Comment=Launch DirSyncPro Exec=/home/juan/Documents/Leadwerks/Projects/pj01/pj01.sh Icon=/usr/share/icons/HighContrast/32x32/apps/gnomine.png Type=Application and the pj01.sh is: Quote cd /home/juan/Documents/Leadwerks/Projects/pj01 export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" exec "./pj01" "$@" i write the line Quote shutdown -h now after exec, but after pj01 ends, system do not shoot down if I open a terminal, shutdown -h now, works ok i try other combinations but, due to my lack of knowledge on the subject... i somewhat lost Quote cd /home/juan/Documents/Leadwerks/Projects/pj01 export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" exec "./pj01" "$@" shutdown -h now and with the !bin/bash Quote #!/bin/bash cd /home/juan/Documents/Leadwerks/Projects/pj01 export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" exec "./pj01" "$@" shutdown -h now Juan Quote Link to post Share on other sites
aiaf 226 Posted April 11, 2019 Share Posted April 11, 2019 Im not near my linux machine to test. Try like this: ./pj01 "$@" I think exec will terminate the current shell and replace it with your process. Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 i placed a "ls" instead a shotdown, but nothing is executed after the leadwerks app Quote Link to post Share on other sites
aiaf 226 Posted April 11, 2019 Share Posted April 11, 2019 Hmm Ok , ignoring that Deskotp autostart and just running your pj01.sh from console , that works ? Ill get to my linux machine and do some tests later. Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 thanks, but nope if i open a terminal and execute the pj01.sh script, the leadwerks app starts ok, and after it, simply the terminal again last line of leadwerks throws : AL lib: (EE) alc_cleanup: 1 device not closed then, the propmt. (and, no other command on the script seems to be executed) Quote Link to post Share on other sites
Ma-Shell 158 Posted April 11, 2019 Share Posted April 11, 2019 Just remove "exec". As @aiaf mentioned, by writing "exec", the process running the bash-script is replaced with the new one and thus the script is not further executed. Just leave out that one word and you should be fine. Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 Ah, ok! yes, now, it shutdown if i run it from a terminal not if I use the .desktop shortcut Quote cd /home/juan/Documents/Leadwerks/Projects/pj01 export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}" ./pj01 "$@" shutdown -h now this is the pj01.sh now Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 this is the hardware: Quote Link to post Share on other sites
Charrua 115 Posted April 11, 2019 Author Share Posted April 11, 2019 the thing now is how or from where I execute this script, because if i launch it from .config/autostart it start the leadwerks app, but do not shutdown the system my idea was that turning on the PC the app autostart and when quitting it, the system shutdown Is there other way to autostart an app? Quote Link to post Share on other sites
aiaf 226 Posted April 12, 2019 Share Posted April 12, 2019 Theres another way. Create in home directory the file: .xsessionrc And run your program from there dont forget the & at end. For example to autorun an gedit editor content should be: gedit & Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 Thanks, I'll try it as soon as I get home. Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 well, if i place a .xsessionrc file with: Quote /home/juan/Documents/Leadwerks/Projects/pj01 gedit "pj01.sh" & then ubuntu starts, exec gedit and gedit open the pj01.sh file located in the above directory but if, instead of gedit i place ./pj01.sh then LE app do not start Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 well, now I have another problem, my bad i placed a shutdown line after gedit, to test if the systems shotsdown after gedit, and found that the system start and shutdown (no gedit) is there a way of intercept startup and open a terminal so I can delete the .xsession file? thanks Quote Link to post Share on other sites
Ma-Shell 158 Posted April 12, 2019 Share Posted April 12, 2019 Which bootloader do you use? In the case of grub (Ubuntu default), you can press "e" before the countdown runs out and then modify the boot-string by simply appending "init=/bin/bash" to the end of the line which starts with "linux /boot/vmlinuz...". You might need to manually mount your harddrives before you can access them, not sure. 1 Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 drives were mounted but as ro, did a mount -o remount rw / then nano .xsessionrc delete the "shutdown..." line and voila... all is working again thank you very much Quote Link to post Share on other sites
Josh 10,028 Posted April 12, 2019 Share Posted April 12, 2019 Wow, cool. You must tell us more about this project! Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 It's more hardware than software, leadwerks part is to have something to shoot :). Guns have infrared lasers, a camera system detects where the gun is in the screen, then with some maths to translate corrds to leadwerks, a camera pick, and that's it. Simply put. Electronics simulate the gun behavior, and as you will see, I'm not an expert RECORTAR_20190410_105041.mp4 RECORTAR_20190410_104628.mp4 1 Quote Link to post Share on other sites
carlb 40 Posted April 12, 2019 Share Posted April 12, 2019 wow i want to have a go at that can not wait to see it all done and working nice one Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 He he, me too! This video is of a couple of years when we build the demonstration prototype. test4.mp4 2 Quote Link to post Share on other sites
Thirsty Panther 466 Posted April 12, 2019 Share Posted April 12, 2019 Thought of using a VR headset with this? Quote Link to post Share on other sites
Charrua 115 Posted April 12, 2019 Author Share Posted April 12, 2019 Not yet, but, if the project continues, it should be a next step or something to take into consideration. A 360 degrees detection system should be possible, but, more complex and expensive 1 Quote Link to post Share on other sites
Josh 10,028 Posted April 13, 2019 Share Posted April 13, 2019 Wow, that is cool. Quote Link to post Share on other sites
Charrua 115 Posted April 13, 2019 Author Share Posted April 13, 2019 Yes, so excited to see it almost finished. Guess next month will be installed and working... And perhaps I'll see some money Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.