Resize gnome键绑定三分之一窗口大小

Resize gnome键绑定三分之一窗口大小,resize,key-bindings,gnome,Resize,Key Bindings,Gnome,我想创建键绑定,将当前窗口大小水平设置为屏幕大小的三分之一,垂直设置为最大,并将其定位在屏幕的左、中或右三分之一。我怎样才能做到这一点呢?xbindkeys和xdotool 使用xbindkeys,您可以独立于窗口管理器使用Shortcutus。 xdotool允许移动和调整窗口大小 通过以下方式安装: sudo apt-get install xbindkeys sudo apt-get install xdotool 默认配置 默认设置显示快捷方式绑定的外观。创建它并查看文件内容 xb

我想创建键绑定,将当前窗口大小水平设置为屏幕大小的三分之一,垂直设置为最大,并将其定位在屏幕的左、中或右三分之一。我怎样才能做到这一点呢?

xbindkeys和xdotool

使用xbindkeys,您可以独立于窗口管理器使用Shortcutus。 xdotool允许移动和调整窗口大小

通过以下方式安装:

sudo apt-get install xbindkeys 
sudo apt-get install xdotool 
默认配置

默认设置显示快捷方式绑定的外观。创建它并查看文件内容

xbindkeys --defaults > ~/.xbindkeysrc
使用编辑器编辑~/.xbindkeysrc并输入:

"/bin/bash ~/placewindow.sh left"
    control + l

"/bin/bash ~/placewindow.sh middle"
    control + m

"/bin/bash ~/placewindow.sh right"
    control + r
创建shell脚本

使用文本编辑器创建一个shell脚本,对于我们的用例,我将其命名为~/placewindow.sh:

#!/bin/bash

width=`xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*(([0-9]+)x([0-9]+)).*$/\2/'`
height=`xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*(([0-9]+)x([0-9]+)).*$/\3/'`

case "$1" in
    left)       
       xdotool windowsize `xdotool getactivewindow` `expr $width / 3` $height
       xdotool windowmove `xdotool getactivewindow` 0 0
       ;;
    middle)
       xdotool windowsize `xdotool getactivewindow` `expr $width / 3` $height
       xdotool windowmove `xdotool getactivewindow` `expr $width / 3` 0
       ;;
    right)
       xdotool windowsize `xdotool getactivewindow` `expr $width / 3` $height
       xdotool windowmove `xdotool getactivewindow` `expr $width \* 2 / 3` 0
       ;;
esac
使其可执行:

chmod +x placewindow.sh
提示

对~/.xbindkeysrc进行更改后,您需要

killall xbindkeys
xbindkeys 
使更改立即激活

演示

现在按CTRL+l、CTRL+m或CTRL+r时,活动窗口的大小和位置将变大。看起来是这样的:


没人?太棒了!我无法让它与xbindkeys一起工作,但将您的代码与gnome键盘菜单项中的键绑定相结合就成功了!最棒的是:你教我如何钓鱼,而不仅仅是给我一条鱼