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 fi
} }
function list_applications() { function check_wmctrl() {
list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g') wmctrl -h &> /dev/null
for process in ${list_raw}; do error=$?
echo "${process}" if [ ${error} -ne 0 ] ; then
done 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() { function list_applications_icons() {
list_applications | while read current_app ; do wmctrl -l | while read current_app ; do
echo " ${current_app}" echo " ${current_app}"
done done
} }
load_theme load_theme
check_wmctrl
list_output=$(list_applications_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " window:") 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) 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 if [ -z "${run_output}" ] ; then
echo "# Selection window canceled" echo "# Selection window canceled"
else else
xdotool search ".*${run_output}.*" windowactivate &> /dev/null wmctrl -ia "${run_output}" &> /dev/null
fi fi