dmenu-scripts/dmenu_drun

76 lines
2.2 KiB
Plaintext
Raw Normal View History

2022-05-29 15:49:43 +02:00
#!/bin/bash
##############################################################
# dmenu_drun - dmenu script that simulates 'rofi -show drun' #
# #
# Author: q3aql <q3aql@duck.com> #
2022-07-10 16:21:44 +02:00
# Last update: 10-07-2022 #
2022-05-29 15:49:43 +02:00
##############################################################
2022-07-10 16:21:44 +02:00
# Configuration variables
load_theme_path="${HOME}/.dmenu"
load_themes="${load_theme_path}/themes"
load_theme_file="${load_theme_path}/load_theme"
2022-05-29 15:49:43 +02:00
desktop_files="/usr/share/applications"
desktop_files_home="${HOME}/.local/share/applications"
2022-07-10 16:21:44 +02:00
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 list_desktop_files() {
2022-05-29 15:49:43 +02:00
if [ -d "${desktop_files}" ] ; then
ls -1 "${desktop_files}/" | grep ".desktop"
fi
if [ -d "${desktop_files_home}" ] ; then
ls -1 "${desktop_files_home}/" | grep ".desktop"
fi
}
2022-07-10 16:21:44 +02:00
function list_desktop_icons() {
2022-05-29 15:49:43 +02:00
list_desktop_files | while read current_desktop ; do
echo " ${current_desktop}"
done
}
rundesk () {
if [ -z ${1} ] ; then
echo "No file entry"
else
if [ -f "${1}" ] ; then
2022-07-10 16:21:44 +02:00
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1" | head -1)"
2022-05-29 15:49:43 +02:00
else
echo "File does not exist"
fi
fi
}
if [ -f /usr/bin/dex ] ; then
runDesktop="dex"
else
runDesktop="rundesk"
fi
2022-07-10 16:21:44 +02:00
load_theme
list_output=$(list_desktop_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -p " drun:")
2022-05-29 15:49:43 +02:00
run_output=$(echo ${list_output} | cut -c 4-999)
system_file=$(echo -n ${desktop_files}/ ; echo ${run_output})
home_file=$(echo -n ${desktop_files_home}/ ; echo ${run_output})
if [ -f "${system_file}" ] ; then
${runDesktop} "${system_file}"
elif [ -f "${home_file}" ] ; then
${runDesktop} "${home_file}"
fi