Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am wondering if there is a way I can launch libreoffice so it does document recovery or exits. I want this so when my computer boots up and I log in I am immediately prompted with document recovery. I want libreoffice to exit if there are no documents to recover. Is there a command line argument that will achieve this I can add to my gnome session?

share|improve this question

1 Answer 1

I want libreoffice to exit if there are no documents to recover.

Isn't that superfluous ?
Here's one possible solution. It will only start LibreOffice (LO) if there's actually any document to recover. Otherwise nothing will happen.
LO saves the information needed to restore all open documents in case of a crash in so called "Temporary files". The default location (in linux) is /tmp and LO saves the data in some directories under /tmp.

  • Change that location to a dedicated directory for temporary files, preferable under $HOME:

Create new dir:

mkdir -p ~/.cache/lo

Start LO and go to Tools - Options - LibreOffice - Paths
Select Temporary files and click Edit (or double click the entry) Select (navigate to) the newly created directory:

/home/YOURUSERNAME/.cache/lo

save, close LO. So from now on LO will place the temporary files (with names like lu2s2clv.tmp, lu2s2clx.tmp, lu2s2cly.tmp etc) in a directory with a similar name, e.g. lu2s2ckt.tmp under ~/.cache/lo. It's only a matter of checking if there's anything to recover and fire up LO.

  • Create a script:
#!/bin/sh

sleep 2
[ -e ~/.cache/lo/*.tmp ] && libreoffice

save it somewhere in your $PATH e.g. /usr/local/bin/odrecover, make it executable.
Then fire up gnome-session-properties and add /usr/local/bin/odrecover to your start-up programs. Next time you log in, if there's any document to recover LO will automatically prompt you with document recovery.


Note: sleep 2 in the above script is needed on my system so that LO starts after gpasted (clipboard manager daemon) otherwise, for some unknown reason, gpasted goes crazy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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