From 2defffd52188d5302978eb28e13c30e12a9a8e8b Mon Sep 17 00:00:00 2001 From: q3aql Date: Sat, 16 Jul 2022 13:01:29 +0200 Subject: [PATCH] Use wmctrl for show and select windows (dmenu_wrun) --- dmenu_wrun | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/dmenu_wrun b/dmenu_wrun index e1f75f4..d9563a8 100755 --- a/dmenu_wrun +++ b/dmenu_wrun @@ -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