Article 5BTRM [SOLVED] close all except selected window

[SOLVED] close all except selected window

by
blueray
from LinuxQuestions.org on (#5BTRM)
I want to close all instance of nemo file browser except the selected window.

I have to following script to do that.

Code:#!/bin/bash

not_to_close=$(xdotool selectwindow)
class_name=$(xprop WM_CLASS | cut -d '"' -f2)

for i in $(xdotool search --desktop 0 --class "$class_name"); do
if [ "$not_to_close" != "$i" ]; then
xdotool windowclose "$i"
fi
doneHowever, it has a small issue. I have to click twice (once for xdotool once for xprop), which I do not want to do.

How can I reduce the click to one?

P.S. I know I can hardcode the class name using --class "nemo", but it has other issues in addition to not being generic.latest?d=yIl2AUoC8zA latest?i=PqwnpjMgp0o:a6B1xA_OiVw:F7zBnMy latest?i=PqwnpjMgp0o:a6B1xA_OiVw:V_sGLiP latest?d=qj6IDK7rITs latest?i=PqwnpjMgp0o:a6B1xA_OiVw:gIN9vFwPqwnpjMgp0o
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments