aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/books.sh
diff options
context:
space:
mode:
authoromagdy <omar.professional8777@gmail.com>2024-11-18 22:59:00 +0200
committeromagdy <omar.professional8777@gmail.com>2024-11-18 22:59:00 +0200
commitda805b1ecdd1963f490a747670460e97474e1eb8 (patch)
tree6c1ec95aea35393355a6996375648fdf185ff68d /scripts/.scripts/books.sh
parent750e399f5f1ddfdafbe50c49c5257b2de8a5e08c (diff)
downloaddotfiles-da805b1ecdd1963f490a747670460e97474e1eb8.tar.xz
dotfiles-da805b1ecdd1963f490a747670460e97474e1eb8.zip
Nothing worth mentioning
Diffstat (limited to 'scripts/.scripts/books.sh')
-rwxr-xr-xscripts/.scripts/books.sh29
1 files changed, 24 insertions, 5 deletions
diff --git a/scripts/.scripts/books.sh b/scripts/.scripts/books.sh
index 307ec89..6c49d62 100755
--- a/scripts/.scripts/books.sh
+++ b/scripts/.scripts/books.sh
@@ -9,14 +9,33 @@
# #
##################################################################
-path="/run/media/omar/Storage/omar/Books"
-choice=$(ls -a "$path" | dmenu -i -l 10)
+# 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
- choice=$(ls -a "$path/$new_choice" | dmenu -i -l 10)
- new_choice+="/"
- new_choice+=$choice #path/books for cs/
+ # 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"