aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/books.sh
blob: 6c49d62e713d4d6b08f16b0dcfff711ab0392ac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
##################################################################
#  ___                         __  __                 _          #
# / _ \ _ __ ___   __ _ _ __  |  \/  | __ _  __ _  __| |_   _    #
#| | | | '_ ` _ \ / _` | '__| | |\/| |/ _` |/ _` |/ _` | | | |   #
#| |_| | | | | | | (_| | |    | |  | | (_| | (_| | (_| | |_| |   #
# \___/|_| |_| |_|\__,_|_|    |_|  |_|\__,_|\__, |\__,_|\__  |   #
#                                           |___/       |___/    #
#                                                                #
##################################################################

# Set the path to the books directory
path="/mnt/Storage/omar/Books/"

# Detect whether we're in a Wayland or X11 session
if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
  # Wayland session - use wofi
  launcher="wofi --dmenu -i -l 10"
elif [ "$XDG_SESSION_TYPE" = "x11" ]; then
  # X11 session - use dmenu
  launcher="dmenu -i -l 10"
else
  echo "Error: Could not detect display server (Wayland or X11)."
  exit 1
fi

# Initial directory to choose from
choice=$(ls -a "$path" | $launcher)

# Initialize the new choice as the first directory selected
new_choice=$choice

# Loop through directories until a file is selected
while [ -d "$path/$new_choice" ]; do
  # Recurse into the selected directory and show options again
  choice=$(ls -a "$path/$new_choice" | $launcher)
  new_choice+="/$choice" # Append the choice to the path
done

# Open the selected file with zathura in fullscreen mode
zathura --mode fullscreen "$path/$new_choice"