温馨提示×

debian compton怎样设热键

小樊
46
2026-10-13 18:08:08
栏目: 智能运维

在 Debian 上给 Compton(通常已是 Picom 的前身) 设置“热键”,一般分两种需求:

  1. 用热键开关 Compton(启动/停止)
  2. 用热键切换 Compton 配置(如开关阴影、透明)

Compton 本身没有内置热键功能,需要借助窗口管理器或热键工具。


一、最常用方案(推荐)

1️⃣ 使用 xbindkeys + 脚本

安装

sudo apt install xbindkeys

创建热键脚本

比如开关 compton:

mkdir -p ~/bin
nano ~/bin/toggle-compton.sh

内容:

#!/bin/bash
if pgrep -x compton > /dev/null; then
    pkill -x compton
else
    compton &
fi

赋予执行权限:

chmod +x ~/bin/toggle-compton.sh

配置 xbindkeys

nano ~/.xbindkeysrc

示例(Super + C 切换):

"~/bin/toggle-compton.sh"
    Mod4 + c

启动 xbindkeys:

xbindkeys

(可加入 ~/.xinitrc 或自动启动)


二、如果你用 i3 / bspwm / openbox

i3 示例

在 ~/.config/i3/config:

bindsym $mod+c exec ~/bin/toggle-compton.sh

三、热键切换不同 Compton 配置

例如:

  • 透明模式
  • 无阴影模式

脚本示例:

#!/bin/bash
pkill -x compton
compton --config ~/.config/compton/transparent.conf &

绑定不同热键即可。


四、Compton 已停止维护(建议)

Debian 新版本更推荐 picom:

sudo apt install picom

配置和热键方式完全一致。


如果你告诉我:

  • 用的 桌面环境 / 窗口管理器
  • 想用热键 做什么

我可以给你精确配置。

0 踩