Created
November 9, 2024 11:42
-
-
Save oasido/42e14b58a2dc791a98b58efd86b2df5b to your computer and use it in GitHub Desktop.
okular save/restore session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Save and restore Okular sessions | |
set -e | |
dump() { | |
for fd in /proc/$(ps -C okular -o pid= | sed -e's/\s//g')/fd/*; do | |
readlink "$fd" | |
done | grep '.pdf' | |
} | |
save() { | |
dump >~/.okular-session | |
} | |
# we use xdg-open instead of okular so that | |
# it will open the files in new tabs instead | |
# of new windows | |
restore() { | |
while read file; do | |
xdg-open "$file" | |
done <~/.okular-session | |
} | |
case "$1" in | |
save | restore) | |
$1 | |
;; | |
*) | |
echo "valid commands: save, restore" >&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment