--- /dev/null
+#!/bin/bash
+
+# # List all open windows, pipe into dmenu
+# window=$(wmctrl -l | awk '{print $1, $4" "$5" "$6" "$7" "$8" "$9}' | dmenu -i -p "Switch to window:")
+
+# if [ -n "$window" ]; then
+# # Extract window ID and trigger activation
+# wid=$(echo "$window" | awk '{print $1}')
+# wmctrl -i -a "$wid"
+# fi
+
+# Get unique application names using wmctrl, pipe into dmenu
+selected=$(wmctrl -lx | awk '{
+ split($3, a, ".");
+ app = a[length(a)];
+ if (!seen[app]++) print app;
+}' | dmenu -i -p "Switch to application:")
+
+if [ -n "$selected" ]; then
+ # Find the window ID for the selected app name
+ wid=$(wmctrl -lx | awk -v sel="$selected" '{
+ split($3, a, ".");
+ app = a[length(a)] == "" ? $3 : a[length(a)];
+ if (app == sel) {
+ print $1;
+ exit;
+ }
+ }')
+
+ if [ -n "$wid" ]; then
+ # Use xdotool to reliably trigger DWM's tag, monitor, and focus jump
+ xdotool windowactivate "$wid"
+ fi
+fi
+
+
+
+# Display only unique application names in dmenu
+# selected=$(wmctrl -lx | awk '{
+# split($3, a, ".");
+# app = a[length(a)];
+# if (!seen[app]++) print app;
+# }' | dmenu -i -p "Switch to application:")
+
+# if [ -n "$selected" ]; then
+# wid=$(wmctrl -lx | awk -v sel="$selected" '{
+# split($3, a, ".");
+# app = a[length(a)] == "" ? $3 : a[length(a)];
+# if (app == sel) {
+# print $1;
+# exit;
+# }
+# }')
+
+# if [ -n "$wid" ]; then
+# # wmctrl automatically tags this as a pager request (Source 2)
+# wmctrl -i -a "$wid"
+# fi
+# fi