2

I am trying to run a program automatically within a bash script after killing the LXDE session. My script consists of:

#!/bin/sh
pkill lxsession;
sh /home/pi/RetroPie/EmulationStation/emulationstation

I tried this as well:

#!/bin/sh
nohup & pkill lxsession & 
writevt /dev/tty1 'emulationstation'

My aim is to log out of the LXDE session and run EmulationStation on my Raspberry Pi with a bash script. I'm using pkill lxsession; to bypass lxsession's logout confirmation dialog.

As it stands, this script just gets me to the command line from a working LXDE desktop. Thanks for reading.

2
  • Did you get this to work ever? I'm having the EXACT same issue as you with EmulationStation and Raspbian desktop icons :( Jan 25, 2023 at 18:17
  • I never did. You might be able to use systemd though.
    – 66tree
    Jan 26, 2023 at 21:28

3 Answers 3

0

I don't think that is possible. You run this script from a terminal emulator that is itself running within the LXDE session. When you kill the LXDE session, you also kill the terminal and, therefore, your script.

A possible workaround would be to log in via a different tty and run your script there. What exactly are you trying to do? Would a root cronjob work?

1
  • I'm trying to create a shortcut on my desktop that logs out of LXDE/Xorg and then runs the emulator front end EmulationStation which cannot be run while X is running. I was fairly sure it was possible to send a command to a newly opened terminal but I could be mistaken. Thanks for your reply.
    – 66tree
    Sep 22, 2012 at 17:25
0

The writevt isn't available here, but I assume it just emulates tty input.

You could try starting a command in the tty before killing the X session, and have it wait until the X sessoin is killed. How about

#!/bin/sh
writevt /dev/tty1 'sleep 20s; emulationstation'` & 
pkill lxsession
1
  • I had to remove the back-tick before the & to get your code to run. It just dropped me to tty1 just like my code above. Thank you for your suggestion though. There has to be a way to this with bash.
    – 66tree
    Sep 23, 2012 at 1:44
0

Try using 'screen' when you either run the script from the terminal, or when you create a launcher:

screen ./emu-script.sh

screen will keep your terminal session alive even if LXDE kills, or whatever else you have shutdown. That way your script can finish properly

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .