A GUI application is started by the normal user. It's doing stuff with the bootloader and then asks for reboot.

The question is how to implement the second part: after reboot and login into the graphical session, the application must start again automatically.

  • it could probably add itself to the autostart of the session, but it'll start in the next session even if there was no reboot

  • add to the autostart and also look at the time of the last boot, but it's not reliable

  • add to the autostart and create a tmp file, so it will be cleared by the reboot (is it guaranteed?)

  • add to the autostart and add a @reboot cron job (is it working? does it run before the ~/.config/autostart/ of the GUI session?)

What is the best way?

  • Maybe this will help: unix.stackexchange.com/questions/145294/… – Esref Dec 11 '15 at 20:26
  • 1
    @Esref, I would like to stay away from the init scripts because they are in motion caused by the systemd. And also for that application usage of root scripts is an overkill (user init scripts are plainly exotic stuff). – Velkan Dec 11 '15 at 21:13

You may create a temporary file in any tmpfs-mounted filesystem. One of the obvious locations is /dev/shm. The tmpfs does not retain its content after a reboot. So, your autostarted program should check if the file exist and act appropriately

  • What's the difference/advantage compared to the tmp? – Velkan Dec 12 '15 at 9:31
  • @Velkan some distributions do not mount tmp at tmpfs. Some might have no /dev/shm but this is very unlikely. You could make the thing auto-adjustible: create a temp file on a first available tmpfs that the user has write access to and memorise the path in a settings file – Serge Dec 12 '15 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.