I’ve written a bunch of shell script functions that allow me to switch between these 3 apps which require exclusive access to a vt channel: raspbian, emulationstation(/RetroPie), and kodi. My intent is to use them in homebridge-commander so that I can switch between these apps using Siri.
I wrote a function for each system to stop that system, but I have 2 problems.
Each OS will stop, but if I've run Kodi at some point, I don’t see the console when I stop whichever one is currently running. All I see is a black screen. I can start up another app, no problem. I can use the connected keyboard (and type without seeing what I'm typing) or ssh and start up another OS, but stopping one of these apps still results in a black screen. I have functions to switch the app in one call, but I want to be able to simply stop whichever app is running and get to the console.
One manual fix I’ve learned is to type alt+F1. I also discovered that if I type
sudo chvt 2;sudo chvt 1 I can get back to a console I can see. (Note, simply typing
sudo chvt 1 does not work. The screen stays completely black.)
So I think VT1 is getting into a strange state and I figure it must have something to do with the way I’m killing Kodi using pkill.
How do I stop Kodi in a way that returns VT1 back to a working console screen?
Note, manually stopping these apps using the GUI works fine and I get back to a visible console, but I want to be able to control it via a command line call in homebridge-commander.
I discovered recently that the way I'm killing emulationstation (
pkill emulationstatio) doesn't actually stop all its components. I had a game running and tried killing emulationstation, but the game remained on the screen. I couldn't play the game. It just seemed frozen. Also, game play was occasionally freezing, which I suspect was due to previously having killed emulationstation in this fashion and starting it back up.
So what's the best way to stop emulationstation (and any emulators it's running) from the command line?