diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-10-25 13:52:33 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-10-25 13:52:33 +0200 |
| commit | a29840b387d2c0f8601eb05320d909877788564e (patch) | |
| tree | 4e7fc94b4f534e88dac878a3fb533fc54e7954e7 /.scripts/track-books.sh | |
| parent | 1300de8ac1644c767dca77cd4f09cd9f80652f7f (diff) | |
| parent | 26ab5b9b636239f85c06099afa731b75339a4c50 (diff) | |
| download | dotfiles-a29840b387d2c0f8601eb05320d909877788564e.tar.gz dotfiles-a29840b387d2c0f8601eb05320d909877788564e.zip | |
Merge commit '5c7e68e25ab9794024f94ee58a9c312e8d07cbdd'
Diffstat (limited to '.scripts/track-books.sh')
| -rwxr-xr-x | .scripts/track-books.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/.scripts/track-books.sh b/.scripts/track-books.sh new file mode 100755 index 0000000..f13add8 --- /dev/null +++ b/.scripts/track-books.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Created By: srdusr +# Created On: Wed 25 Oct 2023 13:45:52 CAT +# Project: Simple script to track most recent books opened, mainly for neovim usage. + +# Dependencies: inotify-tools + +books_directory="$HOME/documents/books" +recent_books_file="$HOME/.config/nvim/tmp/recent_books.txt" + +inotifywait -m -e CREATE -e OPEN -r "$books_directory" | + while read -r path action file; do + if [[ $file == *.pdf || $file == *.epub ]]; then + echo "$path/$file" >>"$recent_books_file" + # Remove duplicates and overwrite the recent_books_file + sort -u -o "$recent_books_file" "$recent_books_file" + fi + done |
