Is there a way to set the maximum allowed size for maximized windows?

Let me explain, I wish that the maximized windows do not cover the entire desktop, but I can set a margin or area to leave a part of the desktop visible.

For example:

enter image description here

I found a program that does exactly that but only for windows: Change The Maximum Window Size - gHacks Tech News. I imagine there must be something similar for Linux but I can't find it.

  • I think you may achieve(workaround) it with a keyboard shortcut that sets the boundaries or rectangle with xy coordinates using wmctl or xdotool etc.. – UnKNOWn Jul 3 at 17:50

After many tests, solutions using commands and complicated scripts, etc, the best and simple solution that I found was using Conky widgets (yes, amazing); I found this solution accidentally while installing a widget I saw that all maximized windows are fixed to keep the widget in desktop visible.

The important part of the widget is "own_window_type panel" to create a window like a panel in your screen.

Then my solution was create a empty and transparent widget for each position of screen when I need a margin(left, top, bottom, right)

Left widget example:

use_xft yes
xftfont 123:size=6
xftalpha 0.1
update_interval 1
total_run_times 0

own_window yes
own_window_type panel
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_colour 000000
own_window_argb_visual yes
own_window_argb_value 0

double_buffer yes
minimum_size 10 1080
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_shade_color red
default_outline_color green
alignment top_left
gap_x 0
gap_y 1
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale yes
use_spacer yes

All widgets are similar only changing size and the position in the screen.

This very simple solution works like a charm :)

| improve this answer | |
  1. This can be done manually for terminal, Vim,Google Chrome.

  2. You can use xrandr to get/set the screen resolution and then use wmctrl to resize your window

A bash script to resize windows to half their size with wmctrl is

# resizes the window to full height and 50% width and moves into upper right corner

#define the height in px of the top system-bar:

#sum in px of all horizontal borders:

# get width of screen and height of screen
SCREEN_WIDTH=$(xwininfo -root | awk '$1=="Width:" {print $2}')
SCREEN_HEIGHT=$(xwininfo -root | awk '$1=="Height:" {print $2}')

# new width and height

# X, change to move left or right:

# moving to the right half of the screen:
X=$(( $SCREEN_WIDTH / 2 ))
# moving to the left:


wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$X,$Y,$W,$H
  1. To move the windows, go to Settings, Window Manager, and click the Shortcuts tab. The actions you are looking for are named Tile window to the left, Tile window to the top-right, etc.

  2. You can check out a GitHub Repo here

Hope this helps! Best of Luck ;)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.