2 min read

Tiling window management for GNOME Terminal

Some years ago I used pure i3 as window manager. But I wasn't happy with it and still wanted a full desktop environment, so I started using i3 on top of KDE Plasma (see this post for more details). When I started using GNOME on all my devices, I kept using the keyboard shortcuts from my former setups, heavily relied on the workspaces in GNOME, but there is one single application, where I still miss the tiling window management: my terminal. For the other applications, my keyboard shortcuts and usage of the workspaces is almost comparable to a tiling window manager.

I know that Pop!_OS Shell exists, but I feel like it is way too complex for my rather simple use case. So I kept researching and started to use this block of code in my .bashrc:

# Only tile after boot stabilization
if [ "$(awk '{print int($1)}' /proc/uptime)" -gt 120 ]; then

  # Query windows on current workspace via Window Calls extension
  windows_json=$(gdbus call --session \
    --dest org.gnome.Shell \
    --object-path /org/gnome/Shell/Extensions/Windows \
    --method org.gnome.Shell.Extensions.Windows.List \
    | sed "s/^('\(.*\)',)$/\1/")

  # Count GNOME Terminal windows on current workspace
  count=$(echo "$windows_json" | jq '[.[] | select(.wm_class == "org.gnome.Terminal" and .in_current_workspace == true)] | length')

  if [ $(($count % 2)) == 1 ]; then
    # Odd:  Super + E for right half
    ydotool key 125:1 18:1 18:0 125:0
  else
    # Even: Super + Q for left half
    ydotool key 125:1 16:1 16:0 125:0
  fi
fi

It needs the GNOME Extension Window Calls to work and count the number of Terminal instances on the current workspace. It does not shrink windows vertically, because I only use two terminal instances at the same time and I prefer the same height for the command prompt. If I need to have more than 2 instances, I use Alt + Tab rather.

This solution is quite simple, but that's why I like it: it does integrate seamlessly into my window manager & current setup 😄

Chromium as KI Browser

Because Atlas is not released for Linux and I prefer to use no closed source applications, my browser that I use for KI Chats is Chromium which is on the left side of my screen and can be focused by pressing Super + G. The code I use to launch it is this little script:

#!/bin/bash

# Check if Chromium is running
if ! pgrep chromium > /dev/null; then
    # Launch Chromium without shortcut prompt if not running
    chromium-browser --disable-features=GlobalShortcutsPortal &
    sleep 2
    ydotool key 125:1 16:1 16:0 125:0  # Super + Q
else
    busctl --user call org.gnome.Shell /de/lucaswerkmeister/ActivateWindowByTitle de.lucaswerkmeister.ActivateWind>
fi

All you need for it to work is this GNOME Extension.
I did try things like Warp too, but in the end I just keep using good old GNOME Terminal which comes by default 😄

Here is a short screencast which shows the positions of launching two terminals and Chromium:

0:00
/0:13

I pressed these 4 key combinations during the screencast:
Super + Return,
Super + G,
Super + Return,
and finally, Super + G again.

Author: Peter Gerhards