Hey guys,
new to Love, new to Linux, not new to development.
I'm attempting to make a simple graphical launcher that runs an emulator to launch the given rom.
I've created the launcher interface, no problem, but I'm struggling (perhaps with Linux) as to how to exit the launcher, launch the emulator, then re-launch the launcher.
Details:
It's actually a Raspberry Pi 3 with stock OS running from the command line only. NO X. Using SDL for Love and the emulator.
Currently I'm called os.execute to launch the emulator. This line runs, but until I actually shut down the launcher it doesn't run the emulator.
Cheers for any assistance, and apologies if I have not given appropriate detail, please ask for any missing aspects.
Rob
Linux Launcher assistance
Re: Linux Launcher assistance
Hm, I can't reproduce. Maybe you mean that until you shut down the emulator, the launcher doesn't resume execution? Yeah, Lua is very limited. You can't fork. All you can do is launch a new thread and run os.execute() from it, so it doesn't stop the main thread.
Edit: for example:
Edit: for example:
Code: Select all
love.thread.newThread("os.execute('mess -window spectrum')\n"):start()
Re: Linux Launcher assistance
Maybe you can use [manual]io.popen[/manual]?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Linux Launcher assistance
Oops, I stand corrected. io.popen does indeed fork. Problem is that it doesn't let the program terminate until the children have all finished.
Re: Linux Launcher assistance
Thanks for the assistance guys.
To be a little clearer ...
I cannot launch the emulator with a command within love that will either "suspend" my executing launcher, or shutdown the launcher, run the emulator, and when the emulator is exited, return to my launcher.
I tried using newThread, but to some degree it appears to act in a similar fashion to pure os.execute, in that when I shut down the launcher, the thread in the background comes to the fore and is clearly running.
I, however, need to have the thread or whatever instantly made the core running application on request, and then have it shutdown when the emulator is closed.
To be a little clearer ...
I cannot launch the emulator with a command within love that will either "suspend" my executing launcher, or shutdown the launcher, run the emulator, and when the emulator is exited, return to my launcher.
I tried using newThread, but to some degree it appears to act in a similar fashion to pure os.execute, in that when I shut down the launcher, the thread in the background comes to the fore and is clearly running.
I, however, need to have the thread or whatever instantly made the core running application on request, and then have it shutdown when the emulator is closed.
Re: Linux Launcher assistance
I still don't understand. When I write a main.lua like this:
the launcher is not just "suspended", it is SUSPENDED. As in, the window doesn't even refresh. When I close the emulator, execution of the launcher resumes (I get a black window that I can then close). Maybe that's not what you're observing, and you want something like Python's Popen.wait(). https://docs.python.org/2/library/subpr ... en-objects
Well, I may be wrong again, but I don't think such thing exists in Lua.
Code: Select all
os.execute('mess spectrum -window')
Well, I may be wrong again, but I don't think such thing exists in Lua.
Re: Linux Launcher assistance
I think you can use read for the same purpose somehow; I'd have to check some code of mine to be sure and I can't before ~18h.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Positive07
- Party member
- Posts: 1014
- Joined: Sun Aug 12, 2012 4:34 pm
- Location: Argentina
Re: Linux Launcher assistance
So if I understand correctly the behaviour you need is:
Run LÖVE program -> Execute emulator -> User closes emulator -> Shutdown LÖVE program automatically
Then you can call [manual]io.popen[/manual], wait for the process to finish and then calling [wiki]love.event.quit[/wiki]
If you want this instead:
Run LÖVE program -> Execute emulator -> Shutdown LÖVE program automatically -> User closes emulator
You can use [manual]os.execute[/manual] which you can make non-blocking by prepending "&" in Linux or "start" in Windows to your command (I took this from the Lua wiki), and then calling [wiki]love.event.quit[/wiki]
Run LÖVE program -> Execute emulator -> User closes emulator -> Shutdown LÖVE program automatically
Then you can call [manual]io.popen[/manual], wait for the process to finish and then calling [wiki]love.event.quit[/wiki]
If you want this instead:
Run LÖVE program -> Execute emulator -> Shutdown LÖVE program automatically -> User closes emulator
You can use [manual]os.execute[/manual] which you can make non-blocking by prepending "&" in Linux or "start" in Windows to your command (I took this from the Lua wiki), and then calling [wiki]love.event.quit[/wiki]
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Re: Linux Launcher assistance
You have to append "&", not prepend it, like a shell commandPositive07 wrote: You can use [manual]os.execute[/manual] which you can make non-blocking by prepending "&" in Linux or "start" in Windows to your command (I took this from the Lua wiki), and then calling [wiki]love.event.quit[/wiki]
Re: Linux Launcher assistance
Looks like you're right. This did it for me:Nixola wrote:I think you can use read for the same purpose somehow; I'd have to check some code of mine to be sure and I can't before ~18h.
Code: Select all
io.popen('mess spectrum -window', 'r'):read("*a")
love.event.quit()
Who is online
Users browsing this forum: Bing [Bot] and 0 guests