I’m trying to write a script that will exit Kodi, launch Lynx and then restart Kodi after Lynx exits. I can get Kodi to exit, but it just sits at a black screen and Lynx never starts. I was hoping someone here may have some insight. My script is as follows:
Another way of doing this is to write a script (in bash, python or whatever you fancy) that runs in the background, wakes up every 5 seconds (or whatever) and starts Kodi or Lynx alternately if neither is running. The logic would be something like:
kodi_started_last_time = false
do
if neither kodi nor lynx is running (check using ps | grep)
then
if kodi_started_last_time
then
start lynx (detached)
kodi_started_last_time = false
else
start kodi (detached)
kodi_started_last_time = true
fi
fi
sleep 5
repeat
Then, when you exit Kodi, Lynx starts; when you exit Lynx, Kodi starts, and so on.
Thanks to both of you for your suggestions. I’ve now gotten Lynx to launch and present itself using the script below, but it creates three problems as a result:
Lynx is confined to a small square in the top left of the screen.
I can’t pass any variables to Lynx such as -center.
When Lynx is either quit or interrupted, everything freezes and input of any kind is not allowed.
#!/bin/bash
# display notification
kodi-send --action="Notification(Lynx,Launching Lynx Web Browser,4000,/home/osmc/.kodi/addons/script.lynxlauncher/logo.png)"
#clear the virtaul terminal 7 screen
sudo openvt -c 7 -s -f clear
# start lynx launch script on vitrual terminal 7 and detach it
sudo su osmc -c "nohup openvt -c 7 -f -s lynx >/dev/null 2>&1 &" &
# clear the screen again
sudo openvt -c 7 -s -f clear
# wait to make sure lynx is running detached from kodi
sleep 0.5
# stop kodi to reveal lynx
sudo su -c "systemctl stop mediacenter &" &
exit
Edit: don’t start Lynx after Kodi dies, as there is some Getty handling there in our watchdog. Best to have a systemd unit that stops Kodi (ExecStartPre), then starts Lynx, and then it will manage the application running in context better. Then you can also have only one command sudo systemctl start lynx for invocation.
I think that you cannot invoke a script from kodi, that first kills kodi, then starts another program as it will die if kodi stops.
I did a lot of experiments on this when doing retrosmc and openvt seemed the only way as it runs the other script detached from the kodi tty before stopping kodi.
Not sure if that is true for systemd services though
I really do appreciate all the input. It seems like I’ve disappeared, but I’m trying my hand at all the suggestions given. I’m learning a lot about all this as I go and I assumed it would come easier than it has. However, anything worth doing is worth learning. Once completed, this will be used to authenticate Wifi connections at hotels and the like, so it will definitely come in handy when traveling or spending any extended time at a hospital.
With all of your suggestions and the help of Joakim_Sandstrom, this addon is now fully operational. I didn’t ignore any of the ideas shared, it’s just that some are over my head at the moment. However, I am learning, so I hope that I might look at all this again in the future and see everything with greater clarity.
As I mentioned earlier, This will be used primarily to allow Wifi authentication at hotels and the like. Calling a hotel’s technical department can be unreliable at best and using a tethered connection from a phone presents it’s own share of problems for any extended period of time.
For anyone interested, the final scripts are below: