This little script lets you cycle through all your open windows on Linux. I’ve got it bound to Ctrl+Alt+Down and also hooked up to left-click on a custom Polybar module.

#!/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