I have a script that kicks off a new terminal window that I want to move to a specific position on the left terminal using xdotool.
After kicking off the terminal I run
xdotool search --class gnome-term
and I use the returned Window ID in the xdotool windowsize and windowmove commands to size and position the new terminal window.
xdotool windowsize $WIN_ID 1978 407
xdotool windowmove &WIN_ID -26 702
Since I have multiple terminals running I need to identify which WIN_ID is associated with the last terminal window just created.
In the script I execute the below command before launching the new terminal to get a list of existing WIN_IDs.
for i in `xdotool search --class gnome-term`; do id_list="$id_list $i"; done
Sample content of $id_list:
65011713 65011722 65103242 65019818 65029314 65027106
After launcing the new terminal, to identify the new WIN_ID, I run this test.
for WID in `xdotool search --class gnome-term`; do if [[ ! $WID =~ $id_list ]]; then echo "New Window ID = $WID"; fi; done
When I run this command, instead of getting just one (the new) Window ID, I get all the Window IDs associated with the gnome-terminal class. Why is the below command not returning only the WID that isn’t in id_list?
if [[ ! $WID =~ $id_list ]]; then ...
Script:
...
...
# Generate a list of Window IDs for existing gnome-terminal windows
for i in `xdotool search --class gnome-term`; do id_list="$id_list $i"; done
# Kick off a new terminal window
gnome-terminal
# Get the Window ID of the new terminal window
New_WID=`for WID in `xdotool search --class gnome-term`; do if [[ ! $WID =~ $id_list ]]; then echo $WID"; fi; done`
...
...
Thanks for time and feedback!
Tex