dotfiles/.config/dmenu/dmenu_wrun

57 lines
1.8 KiB
Plaintext
Raw Normal View History

2022-05-28 01:39:17 +02:00
#!/bin/bash
2022-05-29 16:41:06 +02:00
################################################################
# dmenu_wrun - dmenu script that simulates 'rofi -show window' #
# #
# Author: q3aql <q3aql@duck.com> #
2022-07-16 13:28:07 +02:00
# Last update: 16-07-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-07-16 13:28:07 +02:00
function check_wmctrl() {
wmctrl -h &> /dev/null
error=$?
if [ ${error} -ne 0 ] ; then
echo " Error: You need install 'wmctrl'" | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " window:"
exit
fi
2022-05-29 16:41:06 +02:00
}
2022-07-10 17:02:20 +02:00
function list_applications_icons() {
2022-07-16 13:28:07 +02:00
wmctrl -l | while read current_app ; do
2022-05-29 16:41:06 +02:00
echo " ${current_app}"
done
}
2022-07-10 17:02:20 +02:00
load_theme
2022-07-16 13:28:07 +02:00
check_wmctrl
list_output=$(list_applications_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " window:")
run_output=$(echo ${list_output} | cut -c 5-999)
echo "# Selected: ${run_output}"
run_output=$(echo "${run_output}" | cut -d " " -f 1)
if [ -z "${run_output}" ] ; then
echo "# Selection window canceled"
2022-05-29 16:41:06 +02:00
else
2022-07-16 13:28:07 +02:00
wmctrl -ia "${run_output}" &> /dev/null
2022-05-29 16:41:06 +02:00
fi