Here it is
wmctrl -i -r $(xwininfo | egrep -om 1 '0x[0-9a-z]+') -e 0,$X,$Y,$WIDTH,$HEIGHT
You can make alias for this one-liner or use this win-resize.sh script:
#!/bin/bash # Using xwininfo and wmctrl to resize a window # Written by Yu-Jie Lin # Public Domain WIN_ID=$(xwininfo | egrep -om 1 '0x[0-9a-z]+') W=$1 H=$2 X=${3:--1} Y=${4:--1} wmctrl -i -r $WIN_ID -e 0,$X,$Y,$W,$H
xwininfo is used for the Window ID only, its click-on-target method fits into the targeted window acquirement very well. Since the first hex string is the Window ID in xwininfo output, therefore the parsing stops when first match occurs (-m 1). -o is to have only matched string printed from egrep. The script accepts two parameters, width and height; position X and Y are optional, will be set to -1 if missing.
I wrote this script for screenshot of window, I want to take shots with window in specific size. There might be some issues with your window manager and screen grabber. I use dwm and xsnap, there is no window decoration to be grabbed since dwm does not have such thing except a border. You will need to adjust some settings in order to keep final image in desired width and height.
0 comments:
Post a Comment