温馨提示×

linux compton如何绑定快捷键

小樊
43
2026-09-22 00:04:13
栏目: 智能运维

在 Linux 中 Compton(现在更多被维护为 picom)本身不负责快捷键绑定,它只是一个窗口合成器(compositor)。
如果你想用快捷键来控制 compton(比如开关、重启、切换配置),需要借助窗口管理器或快捷键工具。

下面按常见场景说明。


一、先确认你用的是 compton 还是 picom

which compton
which picom
  • 有 picom → 用 picom
  • 只有 compton → 用 compton

下面以 compton 为例,picom 同理。


二、常用快捷键需求 & 实现方式

1️⃣ 用快捷键 开关 compton

示例:Toggle 开关

pkill compton && echo "compton off" || compton &

绑定方式取决于你的桌面环境


2️⃣ i3 / i3wm(最常见)

编辑 ~/.config/i3/config:

bindsym $mod+Shift+c exec --no-startup-id pkill compton; exec --no-startup-id compton

或者 toggle 脚本:

#!/bin/bash
if pgrep -x compton >/dev/null; then
    pkill compton
else
    compton &
fi
bindsym $mod+Shift+c exec --no-startup-id ~/.local/bin/compton-toggle

3️⃣ Openbox

编辑 ~/.config/openbox/rc.xml:

<keybind key="C-S-c">
  <action name="Execute">
    <command>bash -c 'pkill compton || compton &'</command>
  </action>
</keybind>

4️⃣ GNOME / KDE

  • 打开 系统设置 → 键盘 → 自定义快捷键
  • 命令:
bash -c 'pkill compton || compton &'
  • 绑定快捷键即可

5️⃣ 使用通用快捷键工具(任何桌面)

xbindkeys

sudo pacman -S xbindkeys   # Arch
sudo apt install xbindkeys # Debian/Ubuntu

~/.xbindkeysrc:

"pkill compton || compton &"
    control+shift + c

启动:

xbindkeys

三、重启 compton(热加载配置)

pkill -HUP compton

或:

compton --restart

快捷键示例(i3):

bindsym $mod+Shift+r exec --no-startup-id pkill -HUP compton

四、切换不同 compton 配置

compton --config ~/.config/compton/blur.conf

快捷键绑定不同配置文件即可。


五、常见误区

❌ Compton 没有“快捷键系统”
❌ 不能在 compton.conf 里绑键
✅ 快捷键必须在 WM / DE / xbindkeys 中实现


如果你告诉我:

  • 使用的 发行版
  • 窗口管理器 / 桌面环境
  • 想绑什么快捷键(开关 / 重启 / 切换效果)

我可以直接给你一份可复制的配置。

0 踩