dmenu scripts

This commit is contained in:
q3aql 2022-05-29 15:49:43 +02:00
parent 3931a7d282
commit d284e9d7f8
4 changed files with 190 additions and 0 deletions

54
dmenu_drun Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
##############################################################
# dmenu_drun - dmenu script that simulates 'rofi -show drun' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
##############################################################
desktop_files="/usr/share/applications"
desktop_files_home="${HOME}/.local/share/applications"
list_desktop_files() {
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
}
list_desktop_icons() {
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
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
list_output=$(list_desktop_icons | dmenu "$@" -p " drun:")
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

64
dmenu_fbrun Executable file
View File

@ -0,0 +1,64 @@
#!/bin/bash
######################################################################
# dmenu_fbrun - dmenu script that simulates 'rofi -show filebrowser' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
######################################################################
show_icon_tree() {
list_tree="${@}"
#current_path=$(pwd)
for current in ${list_tree} ; do
if [ -f "${current}" ] ; then
echo " ${current}"
elif [ -d "${current}" ] ; then
echo " ${current}"
else
echo " ${current}"
fi
done
}
remove_icon() {
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
}
file=1
while [ "${file}" ]; do
file_list=$(ls -1)
file_icon=$(show_icon_tree "${file_list}" | dmenu -p " filebrowser: $(basename $(pwd))")
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

38
dmenu_run Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
############################################################
# dmenu_run - dmenu script that simulates 'rofi -show run' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
############################################################
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
if [ "${current_path}" == "/bin" ] ; then
count_path=$(expr ${count_path} + 1)
else
ls -1 ${current_path}/
count_path=$(expr ${count_path} + 1)
fi
fi
done
}
list_binaries_icons() {
list_binaries | while read current_binary ; do
echo " ${current_binary}"
done
}
list_output=$(list_binaries_icons | dmenu "$@" -p " run:")
run_output=$(echo "${list_output}" | cut -c4-999)
${run_output}

34
dmenu_wrun Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
################################################################
# dmenu_wrun - dmenu script that simulates 'rofi -show window' #
# #
# Author: q3aql <q3aql@duck.com> #
# Last update: 29-05-2022 #
################################################################
list_applications() {
list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g')
for process in ${list_raw}; do
echo "${process}"
done
}
list_applications_icons() {
list_applications | while read current_app ; do
echo " ${current_app}"
done
}
list_output=$(list_applications_icons | dmenu "$@" -p " window:")
run_output=$(echo ${list_output} | cut -c 4-999)
if [ "${run_output}" == "gimp" ] ; then
xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null
elif [ "${run_output}" == "gimp-2.10" ] ; then
xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null
elif [ "${run_output}" == "truecrypt" ] ; then
xdotool search --onlyvisible -classname "${run_output}" windowactivate &> /dev/null
else
xdotool search ".*${run_output}.*" windowactivate &> /dev/null
fi