5

I am using Ubuntu 18.04 with GNOME. I would like to know if there is any functionality that allows to associate multiple windows in such a way that when one of the windows is minimized all the other are too and when the window is restored all the others too.

I.e. I am working with multiple terminal windows and I would like to group the terminals in N groups, in such a way that when I minimize a terminal window all other terminal windows that belong to that group get minimized too.

  • If you want to minimize all windows, use the Hide all normal windows shortcut. By default it is not assigned in Gnome. But, I set it to Super+M to mimic MS Windows usage. (Go to Settings | Devices | Keyboard | Navigation to set it.) – FedonKadifeli Jul 22 at 16:26
  • Related: askubuntu.com/questions/13709/… – Elder Geek Jul 23 at 15:02
  • Please note that I have modified my answer significantly as it relates to Ubuntu 18.04. – Justice for Monica Jul 24 at 14:47
4

The following procedure is only for $XDG_SESSION_TYPE x11.

Notes:

  • It uses xdotool which is in the Universe repository.
  • It assumes you've categorized your terminal windows in such a way that each group has a common string in the title (not present in any other open windows).
  • In the example below, there are two groups each with three open gnome-terminal windows:
    • Earth 1
    • Earth 2
    • Earth 3 and
    • Wind 1
    • Wind 2
    • Wind 3

Important:
To ensure that the terminal window's title does not change, I had to first comment out the following lines from ~/.bashrc. If this is not done, the title will reflect the current working directory instead of retaining the title you set:

case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

I named each window using

echo -en "\033]0;New title\a"

Note that xdotool, as used here, won't handle windows named using

wmctrl -r :ACTIVE: -N "New title"

See the answer to Setting terminal window's title: wmctrl versus xdotool for a thorough explanation.

The following animated gif will illustrate using another "master" terminal, located at the top of the screen in the image, to issue code to minimize or maximize a particular group of windows.

To do so, I added the following functions to my ~/.bashrc:

mmm(){
    echo "enter KEYWORD" && read KEYWORD && xdotool search --name --onlyvisible "$KEYWORD" > /tmp/tmp.txt
}

xwn() {
    while read p; do xdotool windowminimize "$p"; done </tmp/tmp.txt
}

xwx() {
    while read p; do xdotool windowactivate "$p"; done </tmp/tmp.txt
}
  • mmm uses xdotool to search for the string "KEYWORD" provided by the user. "earth" in this example, is common to one group of terminal windows to be acted on. xdotool produces their window identifiers which is directed to a temporary file.
  • xwn uses xdotool's windowminimize action to minimize the windows specified in the temporary file.
  • xwx uses xdotool's windowactivate action to maximize the windows specified in the temporary file.
  • Note that, depending on what else has been done, it maybe necessary to run mmm immediately before xwn or xwx.

Using xdotool to minimize/maximize groups of terminal windows


I had to use mogrify -type Grayscale -depth 7 *.png to scale down the size of the gif.

3

I'm not aware of anything that provides exactly what you're looking for, but you can try this kinda ugly workaround by following the steps below.

  1. Set Ubuntu dock to show windows only from the current workspace.
  2. Enable 'minimise on click' on Ubuntu dock. Once you do this, you'll be able to minimise or restore all windows belonging to a specific application from the current workspace by clicking its icon in the dock.
  3. Use different workspaces to group the windows, e.g. keep all the Terminal windows belonging to the first group in workspace 1, second group in workspace 2 and so on.
0

Ubuntu 19.04 I have not tested this script , feel free to correct me on those keystrokes. you could use a script to minimise the window and other windows by selecting them from a names list and sending the minimise keystroke to them. unfortunately I do not see minimise window shortcut in Gnome keyboard shortcuts. set a shortcut key in Gnome to run this script. keydown alt + space release then m (or enter as minimise is the first in my window min/max/move list) would do the trick though, xdotool keystrokes help here https://www.linux.org/threads/xdotool-keyboard.10528/

#!/bin/bash
names="Firefox Thunderbird Kate Konsole"
echo "$names"
for name in $names
 do
    #         id=$(xdotool search --onlyvisible --name 
"$name")
             id=$(xdotool search --desktop 0 --class  
"$name")
    echo $name $id
if  [ "x$id" = "x" ]
    then
        echo " window not found for "$name""
    else
          xdotool windowactivate --sync $id key  -- 
 clearmodifiers  --delay 100 keydown alt+space 
 xdotool windowactivate --sync $id key  -- 
 clearmodifiers  --delay 100 key enter
     # you can set sleep by a lesser value here like a 
  fraction 0.1   
  sleep 1
  fi
done

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.