2

As i read many PDFs at the same time, i would like to find a solution for Okular to remember the opened files and reopen them, when the Program gets restarted.

This small skript writes the current open document paths to a file:

#!/usr/bin/bash
file="/home/johndoe/.okular_docs"
oku=$(qdbus | grep -i okular)
[ -e $file ] && rm $file
while read line
do
    echo $(qdbus $oku $line org.kde.okular.currentDocument) >> $file
done <<< $(qdbus $oku | grep -E "^/okular[0-9]*$")

Obviously it has to be executed before closing the program or every time i open a new document in okular. Any ideas how to accomplish that?

Then I could change the okular command to xargs -rd'\n' okular < .okular_docs and eventually it would open the last 'session' again.

jo87casi
  • 411
  • 5
  • 15
  • Can you please add some sample output of `qdbus $oku | grep -E "^/okular[0-9]*$"`? I don't use KDE, and even though I have both `qtchooser` and `okular` installed `qdbus | grep -i okular` comes back emptyhandedly even though okular is currently running. – tink May 13 '23 at 20:21
  • 1
    One idea is to modify the program so it updates the file only if Okular is running, and run the program automatically at fixed intervals (e.g. every minute). – pjh May 13 '23 at 23:04

0 Answers0