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