Skip to content

Instantly share code, notes, and snippets.

@bonnebulle
Created March 13, 2025 14:07
Show Gist options
  • Save bonnebulle/35f8cccd1260778dd2bdca9f4cd2f33d to your computer and use it in GitHub Desktop.
Save bonnebulle/35f8cccd1260778dd2bdca9f4cd2f33d to your computer and use it in GitHub Desktop.
xdotool close all current app windows not the active one
#!/bin/bash
current=$(xprop -root | grep '^_NET_ACTIVE_W' | awk -F'# 0x' '{print $2}' | awk -F', ' '{print $1}')
echo current $current
class=$(xdotool getwindowfocus getwindowclassname)
echo class $class
currapp_windows=$(wmctrl -mlpx | grep $class | awk '{print $1}')
echo currapp_windows $currapp_windows
currapp_window_active=$(wmctrl -mlpx | grep $current | awk '{print $1}')
echo currapp_window_active $currapp_window_active
for window in $currapp_windows; do
if [[ $window != $currapp_window_active ]];then
echo "X Fenêtre : $window" # Exemple d'action
wmctrl -ic $window
else
echo "Fenêtre : $window" # Exemple d'action
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment