[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.


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.