1

This question is a follow up to: Manipulate window size in linux via compiled code?

Per the title, I want to resize the active window to half the screen size (either on the left or the right of the screen. I can do this with a bash script as follows (per the answer to the previous question):

#!/bin/bash

w_h=$(xrandr | awk '/\*/{sub(/[0-9\.\*\+]*$/, ""); sub("x", " "); $1=$1/2; print}')
w=${w_h% *} ; h=${w_h#* }

wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized,vert
wmctrl -r :ACTIVE: -e 0,${w},0,${w},${h}

However, this method has a noticeable but not severe lag of 0.25 seconds on my laptop that I would like to get down to 0.1 seconds. How can I achieve the same affect as the above bash script in python?

Community
  • 1
  • 1
jonderry
  • 23,013
  • 32
  • 104
  • 171
  • Just an update, the line: `wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized,vert` should be: `wmctrl -r :ACTIVE: -b remove,maximized_horz,maximized_vert` i.e. **maximized,vert** should be **maximized_vert** – barryels Jan 25 '17 at 06:31

1 Answers1

0

The lag you getting is caused by xrandr command it's going to be slow anyway. You can reduce this time by parsing output of xdpyinfo | grep 'dimensions:'. From python you could call this command using subprocess.Popen.

ILYA Khlopotov
  • 705
  • 3
  • 5