53 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
################################################################
# wofi_run - wofi-dmenu script that simulates 'rofi -show run' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 04-01-2023 #
################################################################
# Configuration variables
load_theme_path="${HOME}/.wofi"
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
}
function list_binaries() {
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
# 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}/
count_path=$(expr ${count_path} + 1)
else
count_path=$(expr ${count_path} + 1)
fi
fi
done
}
function list_binaries_icons() {
list_binaries | while read current_binary ; do
echo "${current_binary}"
done
generate_spaces 75
}
list_output=$(list_binaries_icons | wofi --dmenu -i -p " run")
run_output=$(echo "${list_output}" | cut -c4-999)
${run_output}