The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

Set window to fixed (percentage) size

asked 2013-02-01 08:50:30 +0000

Tom Francart gravatar image

Dear all,

Is there a way to change the size of a window to a certain percentage of its parent container? I'd like shortcuts to swap between a window width of 70%/30% and 30%/70% of the parent container. I've only come across the resize grow/shrink commands, but those don't take into account the current size.

best regards, Tom

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
1

answered 2014-09-30 09:31:53 +0000

ticcky gravatar image

updated 2014-09-30 09:33:40 +0000

Here's my workaround for floating windows to resize window to 400x800px:

for_window [title="Tasks.*"] floating enable; resize shrink width 10000px; resize grow width 400px; resize shrink height 10000px; resize grow height 800px;
edit flag offensive delete link more
1

answered 2013-02-06 16:01:10 +0000

Tom Francart gravatar image

Thanks for your response, Michael!

I wrote the following very simple script (pardon my language, it's my first attempt at python):

import i3
import sys

targetwidth = float(sys.argv[1])

# get currently focused window
current = i3.filter(nodes=[], focused=True)
currentsize = current[0]['percent'] * 100;

d = int(targetwidth - currentsize)

if d>0:
    i3.resize("grow width" + str(d) + " px or " + str(d) + " ppt");
else:
    i3.resize("shrink width" + str(-d) + " px or " + str(-d) + " ppt");

While this works nicely, I'm confused by the px and ppt syntax. The manual states the following:

resize <grow|shrink> <direction> [<px> px] [or <ppt> ppt]

... The optional pixel argument specifies by how many pixels a floating container should be grown or shrunk (the default is 10 pixels). The ppt argument means percentage points and specifies by how many percentage points a tiling container should be grown or shrunk (the default is 10 percentage points).

The way I understand this, is that for a tiling container, the px argument will be ignored and vice versa. This however does not seem to be the case.

i3-msg resize grow width 5 px

Grows my tiling window by what appears to be 5%.

i3-msg resize grow width 5 ppt

Does not have any effect

While if I use

i3-msg resize grow width <anynumber> px 5 ppt

anynumer seems to be ignored.

Perhaps this could be clarified in the user manual?

edit flag offensive delete link more

Comments

The syntax of the resize command already is clarified in the git version: http://build.i3wm.org/docs/userguide.html#resizingconfig

Michael gravatar imageMichael ( 2013-02-07 15:06:44 +0000 )edit

Correct me if I'm wrong, but is the explanation in the manual compatible with the fact that "i3-msg resize grow width 5 px" grows a tiling window by 5 ppt?

Tom Francart gravatar imageTom Francart ( 2013-02-07 15:15:09 +0000 )edit

Well, you are sending a wrong command, so behavior is somewhat undefined (preferably it should error out clearly, though). In case you feel strongly about this, feel free to submit a patch to http://cr.i3wm.org/ or file a bug report at http://bugs.i3wm.org/

Michael gravatar imageMichael ( 2013-02-10 14:51:08 +0000 )edit
0

answered 2013-02-03 12:59:17 +0000

Michael gravatar image

As you figured out, there is currently no way to do that (as of i3 v4.4).

You can write a simple script which uses the IPC interface (see http://i3wm.org/docs/ipc.html) and then sends the necessary commands based on the current percentages.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2013-02-01 08:50:30 +0000

Seen: 2,695 times

Last updated: Sep 30 '14