How can I force terminals to be at least a certain size?

I'd like to prevent any of my Terminator terminals from being smaller than 80x24. That is, I'd be prevented from resizing a terminal to below that size, and if I tried to split a terminal that would be too small, either the existing terminals would be shrunk to fit or the parent and child terminals would be moved to a new window.

I'm willing to change terminal programs if needed, although a good tiling solution like Terminator's is preferable.


Solution 1:

To accomplish what you want, you'll have to edit the source code for gnome-terminal and rebuild it yourself, as the minimum window size is hard-coded into the terminal application. To do this, follow these steps.

First, go to https://launchpad.net/ubuntu/+source/gnome-terminal/3.6.1-0ubuntu4 and download the source files (the file is gnome-terminal_3.6.1.orig.tar.xz). Download this to your ~/Downloads folder.

Then, open a terminal and type the following commands:

cd ~/Downloads

tar -xJf gnome-terminal_3.6.1.orig.tar.xz

This will extract the source. Now, open up your favourite text editor and edit the file ~/Downloads/gnome-terminal-3.6.1/src/terminal-window.c. Navigate to line 3107, where you will find the variables MIN_WIDTH_CHARS and MIN_HEIGHT_CHARS. Edit these, these are the minimum height and width of your terminal window expressed in characters (i.e. a MIN_WIDTH_CHARS of 20 will mean that you can no longer resize the width of the window to below 20 character widths)

Then, to build, in a terminal type cd ~/Downloads/gnome-terminal-3.6.1. Then, run ./configure to generate the makefile (if it complains about any missing packages, install them using apt-get (e.g. if it says "package foo not found" or similar, use sudo apt-get install foo). You can also try installing auto-apt and using sudo auto-apt run ./configure (this will attempt to install all dependencies), but when I tried this it didn't quite catch everything (run standard ./configure afterwards) This may take a few attempts, depending on how many packages are missing.

Once it has generated the makefiles simply type make, followed by sudo make install. This should rebuild the terminal program. Close all terminal windows, and then the next one you start will respect the minimum size you set in the source (i.e. will not resize below the values you defined there).

Solution 2:

  1. Press the super key to open the search lens and look for: main menu
  2. Once the "Main Menu" application is running select "Accessories" on the left menu and then select "Terminal" on the second menu.
  3. Once you have the "Terminal" options is selected press the "Properties" button on the right. A new window will open with the terminal Launcher properties.
  4. Go to the "Command" entry and add this to the end of the entry:

    --geometry=132x24
    

    The finished entry should be:

    gnome-terminal --geometry=132x24
    

That's it. Close the windows and next time you launch the terminal the window will be resized. You may have to logout and log back in to work properly.

(132x24 is just an example, you can use whatever resolution you want)