I have written a bunch of dash scripts that resize and move windows for better efficiency.

The structure is the following: i have a row of 8 windows that are stacked to the bottom of my screen, like thumbnails if you will. Let's call each of those windows miniportal_1,...,miniportal_8

When i want to work with one of them a script resizes it above the row so that it occupies the remaining part of the screen and becomes mainportal

To better visualize, the concept is inspired by the fighter jet F-35 displays (See image)

What i want to do is that if there's already one mainportal present, the miniportal window that i resize replaces it but also that the mainportal window is resized and moved to the former miniportal image. So in short i want to swap the miniportal and portal windows.

I think what i need to do something like that:

1/store the ID, geometry and coordinates of all visible windows using wmctrl

visible_windows_ID_array=wmctrl -l -G | awk '{print S1}'
visible_windows_geometry=same but with different awk option
visible_windows_coordinates= same but with different awk option

2/Do a for loop with an if test to get the ID of the mainportal window

for((i=0;i<${#get_visible_windows_ID_array[@]}; i++ )) do

and this is where i can't find the correct syntax for the If test. I want to do something like that:

if visible_windows_geometry[i]= mainportal geometry  && visible_windows_coordinates[i]= mainportal coordinates then
get visible_windows_ID[i]

Once i have the mainportal window ID i can use wmctrl -r to resize it.

Any idea on how i could do that?


Found the solution, here is one example finding the ID of a miniportal window already present in case you can to move a portal window back to miniportal and hence switch the miniportal window to portal.

function getportalwindowID {
windowsID=($(wmctrl -l -G | awk -v ID=$ID  '{print $ID}'))
windowsgeometry_w=($(wmctrl -l -G | awk -v W=$W  '{print $W}'))
windowsgeometry_h=($(wmctrl -l -G | awk -v H=$H  '{print $H}'))
windowscoordinates_x=($(wmctrl -l -G | awk -v X=$X  '{print $X}'))
windowscoordinates_y=($(wmctrl -l -G | awk -v Y=$Y  '{print $Y}'))

for ((i=0; i<${#windowsID[*]}; i++));
if [ ${windowsgeometry_h[i]} = 180 ] && [ ${windowsgeometry_w[i]} = 320 ] && [ ${windowscoordinates_x[i]} = $(($activescreendisthorizontal+ 0)) ] && [ ${windowscoordinates_y[i]} = 1260 ]; then


echo $portalwindowid




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.