Set Maximum Size for Maximized Windows
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
TEXT
All widgets are similar only changing size and the position in the screen.
This very simple solution works like a charm :)
This can be done manually for terminal, Vim,Google Chrome.
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
#!/bin/bash
# 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:
TOPMARGIN=27
#sum in px of all horizontal borders:
RIGHTMARGIN=10
# 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
W=$(( $SCREEN_WIDTH / 2 - $RIGHTMARGIN ))
H=$(( $SCREEN_HEIGHT - 2 * $TOPMARGIN ))
# X, change to move left or right:
# moving to the right half of the screen:
X=$(( $SCREEN_WIDTH / 2 ))
# moving to the left:
#X=0;
Y=$TOPMARGIN
wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz && wmctrl -r :ACTIVE: -e 0,$X,$Y,$W,$H
To move the windows, go to
Settings
,Window Manager
, and click theShortcuts
tab. The actions you are looking for are namedTile window to the left
,Tile window to the top-right
, etc.You can check out a GitHub Repo here
Hope this helps! Best of Luck ;)