Skip to content

Commit

Permalink
update through script - 2024-11-09 13:40:54
Browse files Browse the repository at this point in the history
  • Loading branch information
oasido committed Nov 9, 2024
1 parent 715ccf7 commit 7260239
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .local/bin/scripts/okular-session
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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

0 comments on commit 7260239

Please sign in to comment.