Xcompmgr

来自 ArchWiki

Xcompmgr 是一个简单的合成器,能够渲染阴影,并且通过使用 transset 实用程序,实现基本的窗口透明。Xcompmgr 仅作为概念验证而设计,是 Compiz 和类似合成管理器的轻量级替代品。

因为它不替换任何现有的窗口管理器,所以对于寻求更优雅桌面的轻量级窗口管理器用户来说,它是一个理想的解决方案。

安装

在安装 Xcompmgr 之前,请确保您已安装并正确配置了 Xorg。要确保 X 服务器启用了 Composite 扩展,请运行

$ 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 是介于 01 之间的数字,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 并在 xcompmgr 之前执行 hsetroot -solid "#000000" (只需输入您想要的颜色代码,而不是 #000000)来解决。或者,如果 xcompmgr~/.xinitrc 中的 exec 之前被调用,您可以将 xcompmgr & 更改为 (sleep 1 && xcompmgr) &,这将fork一个子 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

只需安装 feh 并重启 awesome

分辨率更改后 awesome 中屏幕不更新

当使用外部显示器时,在自动更改显示分辨率时可能会遇到问题:屏幕的一部分会“卡住”并且不再自行更新。此问题是由于初始分辨率更改(发生在 Xcompmgr 启动之前)以及 awesome 通过 feh 设置背景引起的。

要解决此问题,您需要安装 hsetroot 并将以下行放在 .xinitrc 中,紧接在 xcompmgr 之前

hsetroot -solid "#000066"

(您可以将 #000066 替换为您选择的颜色)。