Workaround for gnome-terminal maximize/unmaximize bug

For at least a couple of years, gnome-terminal has had the following annoying bug: if you maximize the window and then unmaximize it, the window ends up smaller than it began. There’s a discussion by the Gnome developers here. It doesn’t look like this bug will be fixed any time soon.

Below is a shell script to work around this problem. It resets the size of the current window to whatever you have specified in the default profile of your gnome-terminal preferences. You’ll need to install the “xterm-resize” package for the resize program.

#!/bin/sh

profile="$(  dconf dump /org/gnome/terminal/legacy/profiles:/ |
             grep '^default=' |
             sed "s/^[^']*'\([^']*\)'.*$/\1/"  )"

rows_cols="$(  dconf dump /org/gnome/terminal/legacy/profiles:/:"$profile"/ |
               awk -F '=' '/^default-size-columns/ { cols = $2 }
                           /^default-size-rows/ { rows = $2 }
                           END { print rows, cols }'  )"

resize -s $rows_cols >/dev/null

1 Like

I just discovered that the ‘gsettings’ command makes things easier. Here’s a much simpler script:

#! /bin/sh
uuid="$(gsettings get org.gnome.Terminal.ProfilesList default | sed "s/'//g")"
get_setting="gsettings get org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$uuid/"
rows="$($get_setting default-size-rows)"
cols="$($get_setting default-size-columns)"
resize -s $rows $cols >/dev/null