2022-05-26 23:26:07 +02:00
|
|
|
#!/bin/bash
|
2022-05-26 21:38:45 +02:00
|
|
|
|
2022-05-29 16:41:06 +02:00
|
|
|
############################################################
|
|
|
|
# dmenu_run - dmenu script that simulates 'rofi -show run' #
|
|
|
|
# #
|
|
|
|
# Author: q3aql <q3aql@duck.com> #
|
2022-11-20 12:30:12 +01:00
|
|
|
# Last update: 20-11-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
|
|
|
|
}
|
|
|
|
|
2022-11-20 12:30:12 +01:00
|
|
|
function generate_spaces() {
|
|
|
|
num_spaces=${1}
|
|
|
|
count_spaces=1
|
|
|
|
while [ ${count_spaces} -le ${num_spaces} ] ; do
|
|
|
|
echo -n " "
|
|
|
|
count_spaces=$(expr ${count_spaces} + 1)
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
function list_binaries() {
|
2022-05-26 23:26:07 +02:00
|
|
|
binaries=0
|
|
|
|
path_binaries=${PATH}
|
|
|
|
count_path=1
|
|
|
|
while [ ${binaries} -eq 0 ] ; do
|
|
|
|
current_path=$(echo ${path_binaries} | cut -d ":" -f ${count_path})
|
|
|
|
if [ -z "${current_path}" ] ; then
|
|
|
|
binaries=1
|
|
|
|
else
|
2022-07-10 17:02:20 +02:00
|
|
|
# Extra code / When /bin is the same that /usr/bin/
|
|
|
|
bin_same=$(ls -la ${current_path} | grep "> usr/bin")
|
|
|
|
if [ -z "${bin_same}" ] ; then
|
|
|
|
ls -1 ${current_path}/
|
2022-05-29 16:41:06 +02:00
|
|
|
count_path=$(expr ${count_path} + 1)
|
|
|
|
else
|
|
|
|
count_path=$(expr ${count_path} + 1)
|
|
|
|
fi
|
2022-05-26 23:26:07 +02:00
|
|
|
fi
|
2022-11-20 12:30:12 +01:00
|
|
|
done
|
2022-05-26 21:38:45 +02:00
|
|
|
}
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
function list_binaries_icons() {
|
2022-05-26 23:26:07 +02:00
|
|
|
list_binaries | while read current_binary ; do
|
|
|
|
echo " ${current_binary}"
|
|
|
|
done
|
2022-11-20 12:30:12 +01:00
|
|
|
generate_spaces 75
|
2022-05-26 23:26:07 +02:00
|
|
|
}
|
|
|
|
|
2022-07-10 17:02:20 +02:00
|
|
|
load_theme
|
2022-07-16 13:28:07 +02:00
|
|
|
list_output=$(list_binaries_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " run:")
|
2022-05-26 23:56:27 +02:00
|
|
|
run_output=$(echo "${list_output}" | cut -c4-999)
|
|
|
|
${run_output}
|