Jump to content
Charrua

how to shootdown ubuntu after application ends

Recommended Posts

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

Share this post


Link to post

Create a run.sh:

#!/bin/bash

exec your app here
shutdown -h now

Make it executable chmod a+x run.sh.

And your done.

Share this post


Link to post

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

 

Share this post


Link to post

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.

Share this post


Link to post

i placed a "ls" instead a shotdown, but nothing is executed after the leadwerks app

 

Share this post


Link to post

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.

Share this post


Link to post

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)

 

Share this post


Link to post

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.

Share this post


Link to post

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

Share this post


Link to post

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?

 

Share this post


Link to post

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 &

 

Share this post


Link to post

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

 

Share this post


Link to post

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

Share this post


Link to post

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.

  • Thanks 1

Share this post


Link to post

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

 

Share this post


Link to post

Wow, cool. You must tell us more about this project!

Share this post


Link to post

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 :)

  • Like 1

Share this post


Link to post

wow i want to have a go at that 

can not wait to see it all done and working nice one

Share this post


Link to post

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 :(

 

  • Like 1

Share this post


Link to post

Yes, so excited to see it almost finished.

Guess next month will be installed and working... And perhaps I'll see some money :)

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...