24

I know you can open an new gnome-terminal maximized by using:

gnome-terminal --maximize

That is not my question. Is there a command that I can use to maximize the current terminal where I am in. I know you can use Ctrl+Super+Up to maximize it, but I want to do it from the terminal using a command.

6 Answers 6

23

You can use wmctrl:

wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz

or xdotool:

xdotool windowsize $(xdotool getactivewindow) 100% 100%

For more info, see man wmctrl and man xdotool.

If you don't have these packages installed, you can install them using the following comand:

sudo apt-get install wmctrl xdotool
6
  • 4
    I used wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz to prevent toggling an already maximized window to an unmaximized one. Also, I've used if command -v wmctrl >/dev/null 2>&1 then echo 'y' fi as per stackoverflow.com/a/677212/165330 . Jan 26, 2016 at 21:11
  • 1
    dunno about the former, but the latter doesn't maximize, it changes the window's size. different thing.
    – phil294
    Mar 7, 2016 at 1:09
  • Trivial note, if a monitor is being specified using x/y dimensions, and the window is already maximised on the non-targetted monitor, combining the dimensions with -e and maximising with -b add,max... will not switch the monitor (it can't move it if it's already maximised) Jun 24, 2016 at 20:26
  • 1
    I ended using both tools ,wmctrl and xdootool with couple of aliases. alias wmax="xdotool key ctrl+super+Up" alias wmin="xdotool key ctrl+super+Down key ctrl+super+Down" alias wl="xdotool key ctrl+super+Left" alias wr="xdotool key ctrl+super+Right" alias wt=" wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz "
    – m3nda
    Mar 7, 2017 at 8:00
  • 1
    none of them maximize the window, they just change the size.
    – Rainb
    Dec 10, 2020 at 7:34
7

You can send keystroke combinations directly to a window using the xdotool command-line X11 automation tool e.g.

xdotool key ctrl+super+Up

In general it is necessary to specify the target window to receive the keystrokes, but the default is to send them to the active window so in this case no additional window target is required

The xdotool package is not installed by default but you can add it from your favourite package manager / software center or using apt-get

sudo apt-get install xdotool

Then edit your ~/.bash_aliases file and add the following line

alias wmax='xdotool key ctrl+super+Up'

This will enable you to max any future screen with wmax

1
  • I ended using both tools ,wmctrl and xdootool with couple of aliases. alias wmax="xdotool key ctrl+super+Up" alias wmin="xdotool key ctrl+super+Down key ctrl+super+Down" alias wl="xdotool key ctrl+super+Left" alias wr="xdotool key ctrl+super+Right" alias wt=" wmctrl -r :ACTIVE: -b toggle,maximized_vert,maximized_horz "
    – m3nda
    Mar 7, 2017 at 8:03
4

On Ubuntu 14.04 while in the terminal window, just pressing F11 does the thing.

2
  • 2
    The OP was asking about using the command line, not pressing keys...
    – jchanger
    Nov 20, 2015 at 9:35
  • Right. Anyway...
    – 4pie0
    Jul 11, 2016 at 9:01
1

For Ubuntu 18.04 this works (e.g. added those lines to the end of .bashrc; g might stand for gui, just to avoid conflicts with other similar names):

alias gmax='xdotool key super+Up'
alias gwin='xdotool key super+Down'
alias gmin='xdotool key super+h'

Please not that after calling 'gmin' on the shell your focus will go to somewhere else. If using a script then you dont have to care. At the keyboard you have to use e.g. your pointing device for returning to your console.

Evidently the installation of the used 'xdotool' needs to be performed one time for the machine:

sudo apt-get install xdotool
0

If you have xdotool version 2021x (currently, on Ubuntu it's still at 2016x), you can windowstate like this:

xdotool getactivewindow windowstate  --add MAXIMIZED_HORZ windowstate --add MAXIMIZED_VERT

Details:

Usage: windowstate [options] [window=%1]
If no window is given, %1 is used. See WINDOW STACK in xdotool(1)
--add property  - add a property
--remove property - remove a property
--toggle property - toggle a property
property can be one of 
MODAL, STICKY, MAXIMIZED_VERT, MAXIMIZED_HORZ, SHADED, SKIP_TASKBAR, 
SKIP_PAGER, HIDDEN, FULLSCREEN, ABOVE, BELOW, DEMANDS_ATTENTION
-1

it's so simple, just press F11 in your keyboard. F11

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .