dmenu-scripts/dmenu-file-handler

39 lines
824 B
Plaintext
Raw Normal View History

2021-03-13 18:09:41 +01:00
#!/bin/sh
# feed the script with your directory path
# and it will list all your files and open them
# in your prefered program with xdg-open
2022-10-30 16:07:16 +01:00
. $HOME/.config/dmenu/config
2021-04-14 15:07:14 +02:00
# cd into the given directory
cd $1
# a functions that list all everything in a directory and gives back the chosen one
choice (){
2022-07-17 11:03:13 +02:00
(ls -1 -a | $DMENU -l 30 -p "Choose your file!")
2021-04-14 15:07:14 +02:00
}
# first choice
dir=$(choice)
# while the coice is not a file do what is inside
while [ ! -f "$dir" ]
do
# first we check if it is a single dot and if it is we exit
[ "$dir" = "." ] && exit
# if dir is empty we exit
[ -z "$dir" ] && exit
2022-04-05 16:59:13 +02:00
2021-04-14 15:07:14 +02:00
# if all check are negative we change into the directory
cd "$dir"
2022-04-05 16:59:13 +02:00
2021-04-14 15:07:14 +02:00
# doing a new check
dir=$(choice)
done
# open the file using xdg-open
xdg-open "$dir"
2022-04-05 16:59:13 +02:00
quick-notify "Opening file" "$dir"