From da805b1ecdd1963f490a747670460e97474e1eb8 Mon Sep 17 00:00:00 2001 From: omagdy Date: Mon, 18 Nov 2024 22:59:00 +0200 Subject: Nothing worth mentioning --- scripts/.scripts/books.sh | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'scripts/.scripts/books.sh') 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" -- cgit v1.2.3