Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 2defffd

Browse files
committed
Use wmctrl for show and select windows (dmenu_wrun)
1 parent 23e25e5 commit 2defffd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

dmenu_wrun

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,29 @@ function load_theme() {
2828
fi
2929
}
3030

31-
function list_applications() {
32-
list_raw=$(xlsclients | cut -d " " -f 3 | sed -e 's/soffice/libreoffice/g')
33-
for process in ${list_raw}; do
34-
echo "${process}"
35-
done
31+
function check_wmctrl() {
32+
wmctrl -h &> /dev/null
33+
error=$?
34+
if [ ${error} -ne 0 ] ; then
35+
echo " Error: You need install 'wmctrl'" | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " window:"
36+
exit
37+
fi
3638
}
3739

3840
function list_applications_icons() {
39-
list_applications | while read current_app ; do
41+
wmctrl -l | while read current_app ; do
4042
echo "${current_app}"
4143
done
4244
}
4345

4446
load_theme
47+
check_wmctrl
4548
list_output=$(list_applications_icons | dmenu -i -nb "${NBCOLOR}" -nf "${NFCOLOR}" -sb "${SBCOLOR}" -sf "${SFCOLOR}" -l 18 -p " window:")
4649
run_output=$(echo ${list_output} | cut -c 5-999)
50+
echo "# Selected: ${run_output}"
51+
run_output=$(echo "${run_output}" | cut -d " " -f 1)
4752
if [ -z "${run_output}" ] ; then
4853
echo "# Selection window canceled"
4954
else
50-
xdotool search ".*${run_output}.*" windowactivate &> /dev/null
55+
wmctrl -ia "${run_output}" &> /dev/null
5156
fi

0 commit comments

Comments
 (0)