安装红帽linux显示半屏,在linux下模拟win+arrow来左右半屏当前窗口

目的

用习惯了windows下的win+arrow来左右窗口,在linux觉得非常不方便的。

所以上网看一下在RHEL6上可以使用的方法。因为不想依赖compiz,所以找到的最好方法是xdotool.

虽然不太完美,但可以满足80%的需求了。

安装xdotool

有两种方法,一种是源码安装,一种是yum安装

源码安装

安装meson

[root@pc-harriszh1 xdotool]# pip3 install meson

Collecting meson

Downloading meson-0.42.1.tar.gz (1.0MB)

100% |████████████████████████████████| 1.1MB 279kB/s

Installing collected packages: meson

Running setup.py install for meson ... done

Successfully installed meson-0.42.1

安装Ninja

[root@pc-harriszh1 libxkbcommon]# cd ..

[root@pc-harriszh1 ~]# git clone git://github.com/ninja-build/ninja.git && cd ninja

Initialized empty Git repository in /root/ninja/.git/

remote: Counting objects: 9572, done.

remote: Total 9572 (delta 0), reused 0 (delta 0), pack-reused 9572

Receiving objects: 100% (9572/9572), 3.39 MiB | 258 KiB/s, done.

Resolving deltas: 100% (6816/6816), done.

[root@pc-harriszh1 ninja]# ./configure.py --bootstrap

bootstrapping ninja...

warning: A compatible version of re2c (>= 0.11.3) was not found; changes to src/*.in.cc will not affect your build.

wrote build.ninja.

bootstrap complete. rebuilding...

[26/26] LINK ninja

[root@pc-harriszh1 ninja]# cp ninja /usr/local/bin/

安装xkbcommon

[root@pc-harriszh1 libxkbcommon]# !meson

meson build -Denable-wayland=false

The Meson build system

Version: 0.42.1

Source dir: /root/libxkbcommon

Build dir: /root/libxkbcommon/build

Build type: native build

Project name: libxkbcommon

Native C compiler: cc (gcc 4.4.7)

Build machine cpu family: x86_64

Build machine cpu: x86_64

Compiler for C supports argument -fvisibility=hidden: YES

Compiler for C supports argument -Wextra: YES

Compiler for C supports argument -Wno-unused-parameter: YES

Compiler for C supports argument -Wno-missing-field-initializers: YES

Compiler for C supports argument -Wpointer-arith: YES

Compiler for C supports argument -Wmissing-declarations: YES

Compiler for C supports argument -Wformat=2: YES

Compiler for C supports argument -Wstrict-prototypes: YES

Compiler for C supports argument -Wmissing-prototypes: YES

Compiler for C supports argument -Wnested-externs: YES

Compiler for C supports argument -Wbad-function-cast: YES

Compiler for C supports argument -Wshadow: YES

Compiler for C supports argument -Wlogical-op: YES

Compiler for C supports argument -Wdate-time: NO

Compiler for C supports argument -Wwrite-strings: YES

Found pkg-config: /usr/bin/pkg-config (0.23)

Dependency xkeyboard-config found: NO

Checking if "__builtin_expect" links: YES

Checking if "__builtin_popcount" links: YES

Header has symbol "eaccess": YES

Header has symbol "euidaccess": YES

Header has symbol "mmap": YES

Header has symbol "mkostemp": YES

Header has symbol "posix_fallocate": YES

Header has symbol "secure_getenv": NO

Header has symbol "__secure_getenv": YES

Configuring config.h using configuration

Checking if "-Wl,--version-script" links: YES

Program bison found: YES (/usr/bin/bison)

Native dependency xcb found: YES 1.11

Native dependency xcb-xkb found: YES 1.11

Program test/symbols-leak-test.bash found: YES (/root/libxkbcommon/test/symbols-leak-test.bash)

Has header "linux/input.h": YES

Library rt found: YES

Program doxygen found: YES (/usr/bin/doxygen)

Program scripts/doxygen-wrapper found: YES (/root/libxkbcommon/scripts/doxygen-wrapper)

Configuring Doxyfile using configuration

Build targets in project: 31

[root@pc-harriszh1 libxkbcommon]# ninja -C build

ninja: Entering directory `build'

[6/96] Compiling C object 'xkbcommon-internal@sta/xkbcommon-internal@sta_parser.c.o'.

In file included from ../src/xkbcomp/parser.y:37:

../src/scanner-utils.h: In function ‘buf_appends’:

../src/scanner-utils.h:163: warning: declaration of ‘str’ shadows a global declaration

../src/scanner-utils.h:141: warning: shadowed declaration is here

[8/96] Compiling C object 'xkbcommon-internal@sta/src_compose_parser.c.o'.

In file included from ../src/compose/parser.c:58:

../src/scanner-utils.h: In function ‘buf_appends’:

../src/scanner-utils.h:163: warning: declaration of ‘str’ shadows a global declaration

../src/scanner-utils.h:141: warning: shadowed declaration is here

../src/compose/parser.c: In function ‘add_production’:

../src/compose/parser.c:363: warning: declaration of ‘next’ shadows a global declaration

../src/scanner-utils.h:117: warning: shadowed declaration is here

[16/96] Compiling C object 'xkbcommon-internal@sta/src_xkbcomp_keymap.c.o'.

../src/xkbcomp/keymap.c: In function ‘CompileKeymap’:

../src/xkbcomp/keymap.c:242: warning: comparison of unsigned expression < 0 is always false

[19/96] Compiling C object 'xkbcommon-internal@sta/src_xkbcomp_rules.c.o'.

In file included from ../src/xkbcomp/rules.c:53:

../src/scanner-utils.h: In function ‘buf_appends’:

../src/scanner-utils.h:163: warning: declaration of ‘str’ shadows a global declaration

../src/scanner-utils.h:141: warning: shadowed declaration is here

[20/96] Compiling C object 'xkbcommon-internal@sta/src_xkbcomp_scanner.c.o'.

In file included from ../src/xkbcomp/scanner.c:26:

../src/scanner-utils.h: In function ‘buf_appends’:

../src/scanner-utils.h:163: warning: declaration of ‘str’ shadows a global declaration

../src/scanner-utils.h:141: warning: shadowed declaration is here

[30/96] Compiling C object 'xkbcommon-internal@sta/src_keysym.c.o'.

In file included from ../src/keysym.c:54:

../src/ks_tables.h:8: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’

../src/ks_tables.h:2418: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’

[96/96] Generating doc with a custom command.

Warning: ignoring unsupported tag `USE_MDFILE_AS_MAINPAGE =' at line 28, file /root/libxkbcommon/build/Doxyfile

Warning: ignoring unsupported tag `HTML_EXTRA_STYLESHEET =' at line 37, file /root/libxkbcommon/build/Doxyfile

Failed to map file extension 'no_extension' to unsupported language 'md'.

Check the EXTENSION_MAPPING setting in the config file.

/root/libxkbcommon/xkbcommon/xkbcommon.h:511: Warning: unable to resolve reference to `include-path' for \ref command

/root/libxkbcommon/xkbcommon/xkbcommon.h:1611: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon.h:1763: Warning: Found unknown command `\endparblock'

/root/libxkbcommon/xkbcommon/xkbcommon.h:1685: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon.h:1686: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-x11.h:48: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon-x11.h:246: Warning: Found unknown command `\endparblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:47: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:56: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:57: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:57: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:59: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:63: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:468: Warning: Found unknown command `\endparblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:83: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:94: Warning: Found unknown command `\endparblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:99: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:103: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:108: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:110: Warning: Unsupported xml/html tag found

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:115: Warning: Found unknown command `\endparblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:116: Warning: end of comment block while expecting command

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:116: Warning: end of comment block while expecting command

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:116: Warning: end of comment block while expecting command

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:154: Warning: Found unknown command `\parblock'

/root/libxkbcommon/xkbcommon/xkbcommon-compose.h:232: Warning: Found unknown command `\endparblock'

上面步骤失败了, 所以手工来拷贝

cp libxkbcommon.so libxkbcommon.so.0 libxkbcommon.so.0.0.0 libxkbcommon-x11.so libxkbcommon-x11.so.0 libxkbcommon-x11.so.0.0.0 /usr/local/li

cp xkbcommon /usr/local/include/ -rf

安装xdotools

git clone https://github.com/jordansissel/xdotool.git

cd xdotool && make && make install

安装后命令可以执行,但没有效果

所以只能直接安装,这有一个问题是需要root权限

yum直接安装

如果有root权限,那么上面的步骤都不需要,直接用yum安装就好

yum install xtodool

安装后是可以使用

绑定快捷键

一种是利用系统快捷键(推荐),一种是利用xbindkeys(除了做这个其实可以做很多事)

使用系统快捷键

mkdir ~/.winarrow

echo '#!/usr/local/bin/zsh' > ~/.winarrow/leftarrow.sh

echo 'xdotool windowsize $(xdotool getwindowfocus) 50% 100% && xdotool windowmove $(xdotool getwindowfocus) 0 y' >> ~/.winarrow/rightarrow.sh

echo '#!/usr/local/bin/zsh' > ~/.winarrow/leftarrow.sh

echo 'xdotool windowsize $(xdotool getwindowfocus) 50% 100% && xdotool windowmove $(xdotool getwindowfocus) 9999 y' >> ~/.winarrow/rightarrow.sh

然后到系统快捷键里把win+left映射到/home/harriszh/.winarrow/leftarrow.sh, 把win+right映射到/home/harriszh/.winarrow/rightarrow.sh,

bVVPIE?w=681&h=603

注意:直接把命令写在"custom shortcut"的command里不起作用, 因为这个命令里有$()命令替换

使用xbindkeys

安装guile

yum install guile

安装guile-config

从centos.pkgs.org下载包

rpm -Uvh /mnt/hgfs/ed/13_linux/gmp-4.3.1-12.el6.x86_64.rpm

rpm -ivh /mnt/hgfs/ed/13_linux/gmp-devel-4.3.1-12.el6.x86_64.rpm

rpm -ivh /mnt/hgfs/ed/13_linux/guile-devel-1.8.7-5.el6.x86_64.rpm

安装xbindkeys

./configura && make && make install

在home目录下vi ~/.xbindkeysrc

"xdotool windowsize $(xdotool getwindowfocus) 50% 100% && xdotool windowmove $(xdotool getwindowfocus) 0 y"

Mod2+Mod4 + Left

"xdotool windowsize $(xdotool getwindowfocus) 50% 100% && xdotool windowmove $(xdotool getwindowfocus) 9999 y"

Mod2+Mod4 + Right

然后添加到系统启动程序里

后言

xdotool的问题是窗口最大化时没法起作用(用alt+space,x来取消最大化),同时左停靠和右停靠时窗口上下没有最大。

希望后面的窗口管理器能自动集成这个功能,靠第三方工具是不太可能完美的

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值