2022-05-26 21:38:45 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
desktop_files="/usr/share/applications"
|
|
|
|
desktop_files_home="${HOME}/.local/share/applications"
|
|
|
|
|
|
|
|
list_desktop_files() {
|
|
|
|
if [ -d "${desktop_files}" ] ; then
|
2022-05-26 23:26:07 +02:00
|
|
|
ls -1 "${desktop_files}/" | grep ".desktop"
|
2022-05-26 21:38:45 +02:00
|
|
|
fi
|
|
|
|
if [ -d "${desktop_files_home}" ] ; then
|
2022-05-26 23:26:07 +02:00
|
|
|
ls -1 "${desktop_files_home}/" | grep ".desktop"
|
2022-05-26 21:38:45 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2022-05-26 23:26:07 +02:00
|
|
|
list_desktop_icons() {
|
2022-05-26 23:56:27 +02:00
|
|
|
list_desktop_files | while read current_desktop ; do
|
|
|
|
echo " ${current_desktop}"
|
2022-05-26 23:26:07 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-05-26 21:38:45 +02:00
|
|
|
rundesk () {
|
|
|
|
if [ -z ${1} ] ; then
|
|
|
|
echo "No file entry"
|
|
|
|
else
|
|
|
|
if [ -f "${1}" ] ; then
|
|
|
|
eval "$(awk -F= '$1=="Exec"{$1=""; print}' "$1")"
|
|
|
|
else
|
|
|
|
echo "File does not exist"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ -f /usr/bin/dex ] ; then
|
|
|
|
runDesktop="dex"
|
|
|
|
else
|
|
|
|
runDesktop="rundesk"
|
|
|
|
fi
|
|
|
|
|
2022-05-26 23:26:07 +02:00
|
|
|
#list_output=$(list_desktop_files | dmenu "$@")
|
2022-05-26 23:56:27 +02:00
|
|
|
#if [ -f "${desktop_files}/${list_output}" ] ; then
|
|
|
|
# ${runDesktop} "${desktop_files}/${list_output}"
|
|
|
|
#elif [ -f "${desktop_files_home}/${list_output}" ] ; then
|
|
|
|
# ${runDesktop} "${desktop_files_home}/${list_output}"
|
|
|
|
#fi
|
|
|
|
|
2022-05-28 01:56:42 +02:00
|
|
|
list_output=$(list_desktop_icons | dmenu "$@" -p " drun:")
|
2022-05-26 23:56:27 +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}"
|
2022-05-26 21:38:45 +02:00
|
|
|
fi
|