I'm trying to use dmenu and wmctrl to write a script that would present to me a list of all currently open windows and then switch to the one I select. It looks something like this:Now, I'm using the window id I get from wmctrl -l (for instance, the 0x00c0005c visible in the screenshot on the 2nd line) to determine exactly which window has been selected (I'm not using the window class because 2 windows belonging to the same application will have the same class, but different ids).The only problem is: wmctrl -i -a works sometimes, but doesn't work other times - and some times, it switches, but to the wrong window! It's quite random. After searching online, the only web page I found that even mentions the issue is this one. It says:WIN as a numerical window ID doesn't seem to work consistently.  Perhaps not all options support it or something crazy is going on. It  used to work very well for me. Re-test.Can anyone tell me how I can resolve or work around this issue?I'm using version 1.07-3 of wmctrl from the official repositories on an up-to-date Arch Linux machine, and Awesome Window Manager, if it helps. Thanks
Inconsistent behaviour of wmctrl -i -a 
arch linux;window manager;awesome;window management
I got the thing working after fiddling around with it today, but I haven't been able to pinpoint what the problem was when I tried it last time (I did switch to Linux Mint in the interim; maybe that solved the issue somehow.)Here's the working script for anyone interested:#!/bin/sh# source dmenu config file if it existsif [ -f $HOME/.dmenurc ]; then    . $HOME/.dmenurcelse    DMENU='dmenu -i'fi# get list of all windows, and their countwmctrl_output=$(wmctrl -lx)win_count=$(echo $wmctrl_output | wc -l)# get rid of the hostname and the number in the 2nd columnhostname=$(uname -n)win_list=$(echo $wmctrl_output | \    sed -r -e 's/[^@]'$hostname'//' | \    sed -r -e 's/ [0-9][0-9]? / /')# select a window ($target) and extract its id ($target_id)target=$(echo $win_list | $DMENU -l $win_count -p Switch to: )target_id=$(echo $target | cut -d' ' -f1)# switch to target windowcmd=wmctrl -i -a \$target_id\eval $cmdand my ~/.dmenurc:DMENU_FONT='-*-*-medium-r-*-*-18-*-*-*-*-*-*-*'DMENU=dmenu -i -fn $DMENU_FONT -nb #1E2320 -nf #DBDBDB -sb #3f3f3f -sf #ffffffAll you need to is put the script somewhere on your $PATH, make it executable, and bind a key to it.