python窗口大小动态变化,使用Python在Linux中将活动窗口的大小调整为屏幕大小的一半吗?...

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?

解决方案

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值