[SOLVED] Reload Launcher from SSH

how to reload Launcher from SSH?

e.g. trying to tinker “Weather App
it works like a part of a Launcher… well, i do not know how to explain it in a better way…
i can’t kill the process, because i don’t see such an apps in the processes by:
> ps -fu cpi

in case of any issues (e.g. app “hangs” or crashes), i would like to restart the Launcher. and since the Launcher (UI) does not respond, i can’t do it from UI…
so, trying to find out how to do it from SSH, without rebooting the device itself (either by long press ‘Power’ button, or “> sudo reboot”).

the final solution by @centuryglass

# Restart the GameShell launcher:
launcherPid=`ps -ax | grep -m 1 "python run.py" | awk '{print $1;}'`
kill -9 "$launcherPid"
cd /home/cpi/launcher/sys.py
DISPLAY=:0 python run.py > /dev/null &

The launcher process is listed as “python run.py”. If you want to restart it, this script will do the job.

# Restart the GameShell launcher:
launcherPid=`ps -ax | grep -m 1 "python run.py" | cut -d " " -f2
kill -9 "$launcherPid"
cd /home/cpi/launcher/sys.py
DISPLAY=:0 python run.py > /dev/null &

I used xdotool to find the name of the launcher process. After installing xdotool, xdotool getactivewindow getwindowpid will give you the process ID of the active window.


thank you!

i tried, and ended up with this changes:

launcherPid=`ps -ax | grep -m 1 "python run.py" | cut -d " " -f3`

maybe smth. windows-related feature/issue (i mean, i mostly use Windows OS).
BUT, after restart Launcher by the script, i need to use cut -d " " -f2 instead of cut -d " " -f3 … it’s weird…

BTW, i tried to use ‘xdotool’ to check “‘ctrl-alt-backspace’ X11 trick” , and it seems that it doesn’t work for me. i have this output:

cpi@clockworkpi:~$ xdotool getactivewindow getwindowpid
Error: Can't open display: (null)
Failed creating new xdo instance

[update]: just found a solution to it: execute in SSH

cpi@clockworkpi:~$ export DISPLAY=:0

and then i can use “xdotool”

I figured out what was wrong with the cut command. ps adds spaces before it prints some of the process IDs in order to make sure all the lines match up, so you’d need -f1 if it doesn’t add any spaces, -f2 if it adds one space, and so on. If you replace cut -d " " -f2 with awk '{print $1;} it’ll work no matter how many spaces ps adds before the process ID.

great! it’s work!

meanwhile i tried to make it work by not to using the cut, but converting grep result into array of words, and take the first one… not an elegant way :thinking: