2022-05-29 16:41:06 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# dmenu_fbrun - dmenu script that simulates 'rofi -show filebrowser' #
|
|
|
|
# #
|
|
|
|
# Author: q3aql <q3aql@duck.com> #
|
2022-07-10 17:02:20 +02:00
|
|
|
# Last update: 10-07-2022 #
|
2022-05-29 16:41:06 +02:00
|
|
|
######################################################################
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
# Configuration variables
|
|
|
|
load_theme_path="${HOME}/.dmenu"
|
|
|
|
load_themes="${load_theme_path}/themes"
|
|
|
|
load_theme_file="${load_theme_path}/load_theme"
|
|
|
|
|
|
|
|
function load_theme() {
|
|
|
|
if [ -f "${load_theme_file}" ] ; then
|
|
|
|
source "${load_theme_file}"
|
|
|
|
else
|
|
|
|
mkdir -p "${load_theme_path}"
|
|
|
|
mkdir -p "${load_themes}"
|
|
|
|
echo "#!/bin/bash" > ${load_theme_file}
|
|
|
|
echo "" >> ${load_theme_file}
|
|
|
|
echo "NFCOLOR=\"#bbbbbb\"" >> ${load_theme_file}
|
|
|
|
echo "NBCOLOR=\"#1f1f35\"" >> ${load_theme_file}
|
|
|
|
echo "SFCOLOR=\"#eeeeee\"" >> ${load_theme_file}
|
|
|
|
echo "SBCOLOR=\"#664477\"" >> ${load_theme_file}
|
|
|
|
source "${load_theme_file}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_icon_tree() {
|
2022-05-29 16:41:06 +02:00
|
|
|
ls -1 | while read current ; do
|
|
|
|
if [ -f "${current}" ] ; then
|
|
|
|
echo " ${current}"
|
|
|
|
elif [ -d "${current}" ] ; then
|
|
|
|
echo " ${current}"
|
|
|
|
else
|
|
|
|
echo " ${current}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
function remove_icon() {
|
2022-05-29 16:41:06 +02:00
|
|
|
entry="${@}"
|
|
|
|
remove_icon_space=0
|
|
|
|
read_entry=$(echo "${entry}" | grep " ")
|
|
|
|
if ! [ -z "${read_entry}" ] ; then
|
|
|
|
remove_icon_space=1
|
|
|
|
fi
|
|
|
|
read_entry=$(echo "${entry}" | grep " ")
|
|
|
|
if ! [ -z "${read_entry}" ] ; then
|
|
|
|
remove_icon_space=1
|
|
|
|
fi
|
|
|
|
read_entry=$(echo "${entry}" | grep " ")
|
|
|
|
if ! [ -z "${read_entry}" ] ; then
|
|
|
|
remove_icon_space=1
|
|
|
|
fi
|
|
|
|
if [ ${remove_icon_space} -eq 1 ] ; then
|
|
|
|
show_output=$(echo "${entry}" | cut -c4-999 | tr -s " " | cut -c2-999)
|
|
|
|
echo "${show_output}"
|
|
|
|
else
|
|
|
|
echo "${entry}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
load_theme
|
2022-05-29 16:41:06 +02:00
|
|
|
file=1
|
|
|
|
while [ "${file}" ]; do
|
2022-07-16 13:28:07 +02:00
|
|
|
file_icon=$(show_icon_tree | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " filebrowser: $(basename $(pwd))")
|
2022-05-29 16:41:06 +02:00
|
|
|
file=$(remove_icon "${file_icon}")
|
|
|
|
echo "# ${file} #"
|
|
|
|
if [ -e "${file}" ]; then
|
|
|
|
owd=$(pwd)
|
|
|
|
if [ -d "${file}" ]; then
|
|
|
|
cd "${file}"
|
|
|
|
else [ -f "${file}" ]
|
|
|
|
if which xdg-open &> /dev/null; then
|
|
|
|
exec xdg-open "${owd}/${file}" &
|
|
|
|
unset file
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|