If I want to run GUI software on my Linux machine, I can do it without a window manager, but I can not discover a way to maximize the window. Is there a reliable way to maximize a window in an x server without a window manager?

3 Answers 3


X servers don't have a notion of “maximized” window. To maximize a window, instruct the application to use a window size that matches the screen size. You can use xdotool for that, though it may be a little difficult to select the window without a window manager — many ways to enumerate and single out windows rely on a window manager.

dimensions=$(xdpyinfo | sed 's/^ *dimension * : *\([0-9]*x[0-9]*\).*/\1/p')
xdotool windowmove "$windowid" 0 0 windowsize "${dimensions%x*}" "${dimensions#*x}"

I would like to open all my text files with Sublime Text, but it does not support a --maximize command line argument, and it either does not remember it window state on Linux and always open unmaximized.

Then, after researching I built this script:

#!/usr/bin/env bash
# run it with /home/user/maximize.sh "Sublime Text" /usr/bin/subl -n
eval "\"$2\" \"$3\" \"$4\" \"$5\" \"$6\" \"$7\" \"$8\" \"${@:9}\""

while [ true ]
    FocusApp=`xdotool getwindowfocus getwindowname`

    if [[ "$FocusApp" == *"$1"* ]];
        # xdotool key super+Up
        wmctrl -ir $(xdotool getactivewindow) -b add,maximized_vert,maximized_horz

You need to install these two things:

sudo apt-get install wmctrl xdotool 

I am not using ``xdotool` to maximize the window because it seems to be bugging with my XFCE4 and when unmaximizing the window, its default size is set to whole window size, i.e., when maximizing the window, it also changed the window size to the match the whole screen size.


  1. How to execute a command on window focus/unfocus?
  2. How to send keystrokes (F5) from terminal to a GUI program?
  3. https://superuser.com/questions/382616/detecting-currently-active-window
  4. https://superuser.com/questions/850145/how-to-use-wmctrl-to-activate-window-of-a-given-class
  5. https://askubuntu.com/questions/703628/how-to-close-minimize-and-maximize-a-specified-window-from-terminal
  • 1
    Are you running a window manager? Without a normal window manager, just using Xepher, xdotool getactivewindow returns Your windowmanager claims not to support _NET_ACTIVE_WINDOW, so the attempt to query the active window aborted. Jul 9, 2019 at 9:21

You can maximize window with xdotool.

For example to start maximized application on user login write something like this to users ~/.xsession:

xrandr --output HDMI-1 --mode 2560x1440
xdotool search --onlyvisible --sync MyPaint windowmove 0 0 windowsize 100% 100% &

xrandr sets desired video mode. Then chain of xdtool's commands searches for a first window with name "MyPaint", moves it to top left corner and resizes it to maximum size. --sync option makes xdtool to wait until suitable window appears, & sends it to wait on background. Then application starts.

You must log in to answer this question.

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