Books menu with bash

2020-08-16 1 min read Learning bash

If you have a folder full of ebooks in various formats and not necessarily one sigle format and you want to have a quick menu to browse though your collection without requiring to open a File Manager then you are going to love this script.

The scripts works by allowing you to browse to the requied folder of your choice and once you select the file, then using xdg-open to open the file with your default viewer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15

path=/Books
cd $path
doc=$(zenity --list --text="Select File" --column=Filename * '..')
while [[ -d "$doc" ]]
do
    doc1=$(cd "$doc";zenity --list --text="Select Something" --column=Filename  * '..')
    [[ ! -n "$doc1" ]] && exit
    doc="$doc/$doc1";
done
if [[ -f "$doc" ]]
then
    echo "Selected $doc.. Opening"
    xdg-open "$doc"
fi

Note you need to change the path variable in the script to your path.

Hope this is useful for you.

comments powered by Disqus