Use wmctrl for show and select windows (dmenu_wrun)

This commit is contained in:
q3aql 2022-07-16 13:01:29 +02:00
parent 23e25e5d09
commit 2defffd521

View File

@ -28,24 +28,29 @@ function load_theme() {
fi
}
function list_applications() {
list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g')
for process in ${list_raw}; do
echo "${process}"
done
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
}
function list_applications_icons() {
list_applications | while read current_app ; do
wmctrl -l | while read current_app ; do
echo " ${current_app}"
done
}
load_theme
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"
else
xdotool search ".*${run_output}.*" windowactivate &> /dev/null
wmctrl -ia "${run_output}" &> /dev/null
fi