This may help some folks who want to use Okular but also have their PDF files reopen between restarts. You can call saveokular.sh from cron and some other tricks so this is all seamless:
$ cat /usr/local/bin/openokular.sh
#!/bin/bash
Check if the file with paths exists
if [ ! -f ~/.okular_open_files.txt ]; then
echo “No saved PDF paths found.”
exit 1
fi
Open PDFs in Okular
echo $1 >> ~/.okular_open_files.txt
sed -i ‘/^$/d’ ~/.okular_open_files.txt
cat ~/.okular_open_files.txt | xargs -d ‘\n’ /usr/bin/orig_okular &
$ cat /usr/local/bin/saveokular.sh
#!/bin/bash
if pid=$(ps -C orig_okular -o pid= | sed -e ‘s/\s//g’) && [[ -n $pid ]]; then
ls -l /proc/“$pid”/fd | grep ‘.pdf’ | awk -F ’ -> ’ ‘{print $2}’ > ~/.okular_open_files.txt
fi
You must log in or register to comment.