The script below enables one to cycle through all open windows in Linux. I have it mapped to the Ctrl-Alt-Down key combination, and also have it assigned to the left-click event on a custom script area on polybar.
#!/usr/bin/env bash
DUNST_TIMEOUT=1500
mapfile -t windows < <( wmctrl -l | cut -d ' ' -f1 )
WINDOW_COUNT=${#windows[@]}
if [ "$WINDOW_COUNT" -eq 0 ]; then
exit 0
fi
if [ "$WINDOW_COUNT" -eq 1 ]; then
WIN_ID="${windows[0]}"
wmctrl -i -a $WIN_ID
exit 0
fi
CURRENT=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)
ME=${CURRENT/0x/0x0}
for i in "${!windows[@]}"; do
if [[ "${windows[$i]}" = "${ME}" ]]; then
INDEX="${i}";
((INDEX++))
fi
done
((WINDOW_COUNT--))
if [ "$INDEX" -gt "$WINDOW_COUNT" ]; then
INDEX=0
fi
WIN_ID="${windows[INDEX]}"
WIN_NAME=$(xprop -id $WIN_ID | awk '/_NET_WM_NAME/{$1=$2="";print}' | cut -d'"' -f2)
dunstify "$WIN_NAME" --timeout=$DUNST_TIMEOUT
wmctrl -i -a $WIN_ID