# fetching names of all open pdf documents (in evince or otherwise)

I frequently have several PDF documents open. These are generally downloaded and install making use of chrome and also quickly opened up making use of evince.

I occasionally intend to linger the state of all my open PDF documents, so I can re - open the very same team of records at a later time.

This primarily takes place when I require to reboot and also what to have the very same set of records re - opened up, yet occasionally I simply intend to maintain a checklist of open records for later on.

Exists a means to get the names of all open pdf documents, from evince or any kind of various other program? or at the very least, exists a means of asking evince to re - open the very same set of records after a reboot?

0
2019-05-13 04:45:32
Source Share

Under the presumption that the PDFs you are watching have the extension.pdf, the adhering to can function to get you a checklist of open PDFs:

$lsof | grep ".pdf$"


If you just ever before make use of Evince, see Gilles' comparable solution. On my equipment (with a couple of pdfs open) presented result as adheres to

evince    6267     myuser   14u      REG    252,0   363755    7077955 /tmp/SM.pdf


To simply get the filenames, we can make use of awk:

$lsof | grep ".pdf$" | awk '{print $9}'  or perhaps much better, $ lsof | awk '/.pdf$/ {print$9}'


We can conserve these cause a documents:

$lsof | awk '/.pdf$/ {print $9}' > openpdfs  And later on, to recover them: $ xargs -a openpdfs evince


To make this take place instantly, you can make use of whatever devices your desktop computer setting gives to run the "conserve" command on exit and also the "open" command on login. A little bit extra effectiveness can be included by making certain that the pdf is returned by lsof are being opened up by your customer. One benefit of this method is that it needs to benefit any kind of pdf visitor that takes command - line debates. One negative aspect is that it relies on documents names ; nonetheless, with a little jabbing, the need of recognizing the filename expansion can possibly additionally be gotten rid of.

0
2019-05-17 17:08:05
Source

lsof details the documents open by a process. Evince does maintain the documents open. If you are the only customer making use of evince, under Linux, below is just how to see what submits it is making use of:

lsof -p $(pidof evince)  To automate this, you'll intend to maintain just the open normal documents of the evince process. Below is a manuscript that outputs the documents names. lsof -n -d0-9999 -Fpctn | # parseable output, pid/command/type/name, only open files sed 's/^p/\np/' | # split each process into a paragraph awk -vRS= '/\ncevince\n/ {print}' | # retain only paragraph(s) with command="evince" sed 's/^t/\nt/' | # split each file into a paragraph awk -vRS= '/^tREG\n/ {print substr($0, 7);}'  # retain only regular files

0
2019-05-17 17:07:10
Source