Xcompmgr
Xcompmgr 是一个简单的 合成器,能够渲染阴影,并且通过使用 transset 工具,可以实现简单的窗口透明度。Xcompmgr 最初仅作为概念验证而设计,是 Compiz 和类似合成管理器的一个轻量级替代方案。
因为它不替换任何现有的窗口管理器,所以对于寻求更优雅桌面的轻量级 窗口管理器 用户来说,它是理想的解决方案。
安装
在安装 Xcompmgr 之前,请确保您已 安装 并正确配置了 Xorg。为了确保 Composite 扩展已为 X 服务器启用,请运行
$ xdpyinfo | grep Composite
Composite
如果没有输出,请将 Composite 选项添加到 xorg.conf 的 Extensions 部分。
/etc/X11/xorg.conf
Section "Extensions"
Option "Composite" "true"
EndSection
可以使用软件包 xcompmgr 安装 Xcompmgr。若要实现透明度,请同时 安装 transset-dfAUR。有关示例,请参阅 Xterm#自动透明度。
配置
要加载 xcompmgr,只需运行
$ xcompmgr -c
要在会话开始时加载它,请将以下内容添加到 xprofile
xcompmgr -c &
您可以尝试使用 -c 以外的其他开关来修改阴影,甚至启用淡入淡出。下面是一个常见的示例:
xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &
有关完整选项列表,请运行
$ xcompmgr --help
窗口透明度
尽管由于性能缓慢,其实用性有限,但 transset-df 工具可用于设置单个窗口的透明度。
要设置程序窗口的透明度,请确保目标程序已运行,然后执行
$ transset-df opacity
其中 opacity 是一个介于 0 和 1 之间的数字,0 表示透明,1 表示不透明。
执行后,鼠标光标将变成十字准星。单击一个窗口,其透明度将更改为指定值。例如,transset-df 0.25 将目标窗口设置为 25% 的不透明度(75% 的透明度)。
技巧与提示
按需启动/停止 Xcompmgr
此脚本允许轻松地(重新)启动和停止合成管理器。
~/.bin/comp
#!/bin/bash
#
# Start a composition manager.
# (xcompmgr in this case)
comphelp() {
echo "Composition Manager:"
echo " (re)start: COMP"
echo " stop: COMP -s"
echo " query: COMP -q"
echo " returns 0 if composition manager is running, else 1"
exit
}
checkcomp() {
pgrep xcompmgr &>/dev/null
}
stopcomp() {
checkcomp && killall xcompmgr
}
startcomp() {
stopcomp
# Example settings only. Replace with your own.
xcompmgr -CcfF -I-.015 -O-.03 -D6 -t-1 -l-3 -r4.2 -o.5 &
exit
}
case "$1" in
"") startcomp ;;
"-q") checkcomp ;;
"-s") stopcomp; exit ;;
*) comphelp ;;
esac
为了方便使用,您可以使用例如 Xbindkeys 将此脚本绑定到热键。这允许快速重启或临时移除合成,而无需中断其他工作。
切换 Xcompmgr
将以下脚本分配给任何热键:
#!/bin/bash
if pgrep xcompmgr &>/dev/null; then
echo "Turning xcompmgr OFF"
pkill xcompmgr &
else
echo "Turning xcompmgr ON"
xcompmgr -c -C -t-5 -l-5 -r4.2 -o.55 &
fi
exit 0
故障排除
登录后背景短暂变为浅灰色 (例如在 Openbox 中)
通过 安装 hsetroot 并通过执行 hsetroot -solid "#000000" (只需输入您想要的颜色代码而不是 #000000) 在 xcompmgr 之前设置背景颜色即可解决此问题。或者,如果 xcompmgr 在 ~/.xinitrc 中的 exec 之前被调用,您可以将 xcompmgr & 更改为 (sleep 1 && xcompmgr) &,这将派生一个子 shell,允许 xcompmgr 在您的窗口管理器启动后执行。
Awesome 中出现 BadPicture 请求
如果在 awesome 中遇到以下错误:
error 163: BadPicture request 149 minor 8 serial 34943 error 163: BadPicture request 149 minor 8 serial 34988 error 163: BadPicture request 149 minor 8 serial 35033
在 Awesome 中分辨率更改后屏幕不更新
当使用外部显示器时,您可能会在自动更改显示分辨率时遇到问题:屏幕的一部分会“卡住”并且不再自行更新。此问题发生的原因是初始分辨率更改(发生在 Xcompmgr 启动之前)以及 awesome 通过 feh 设置背景。
要解决此问题,您需要 安装 hsetroot 并将以下行放在 .xinitrc 中,就在 xcompmgr 之前:
hsetroot -solid "#000066"
(您可以将 #000066 替换为您选择的颜色)。