Compton配置中键盘快捷键怎么设置
导读:Compton快捷键设置指南 核心原则 Compton 本身不提供快捷键功能,需要在窗口管理器(如 i3、Openbox、AwesomeWM)或桌面环境(如 GNOME、KDE Plasma)里绑定按键,通过命令来启动、重启、切换或停止...
Compton快捷键设置指南
核心原则
- Compton 本身不提供快捷键功能,需要在窗口管理器(如 i3、Openbox、AwesomeWM)或桌面环境(如 GNOME、KDE Plasma)里绑定按键,通过命令来启动、重启、切换或停止 Compton。因此“在 Compton 配置里设置快捷键”的正确做法是:在 WM/DE 里绑定按键 → 执行 compton 命令。
在 i3 中绑定快捷键
- 在 ~/.i3/config 中添加 bindsym,例如切换/重启 Compton(按 Alt+Shift+T):
说明:bindsym $mod+Shift+T exec --no-startup-id compton --replace --config ~/.config/compton.conf- $mod 默认通常是 Alt(Mod1),可按需改为 Win(Mod4)。
- 使用 –replace 可在 Compton 未运行时启动,已运行时先替换当前实例。
- 修改后执行 Alt+Shift+R 重新加载 i3 配置,或重登会话生效。
在 GNOME 中绑定快捷键
- 通过 gsettings 添加自定义快捷键(示例把 Ctrl+Alt+C 绑定为切换/重启 Compton):
- 添加自定义快捷键项
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']" - 设置名称、命令、按键
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'Toggle Compton' gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command 'compton --replace' gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding '< Control> < Alt> C' - 图形界面方式:安装 dconf-editor,在 org → gnome → settings-daemon → plugins → media-keys → custom-keybindings 中新增条目并填写名称、命令、绑定。
- 添加自定义快捷键项
使用 xbindkeys 的通用方案(适合 Openbox、Xfce、无桌面环境)
- 安装工具并生成默认配置:
sudo apt update sudo apt install xbindkeys xautomation xbindkeys --defaults > ~/.xbindkeysrc - 绑定示例(示例键位 Ctrl+Alt+Y 切换/重启 Compton):
获取键码与修饰键:运行 xbindkeys -k,按下目标组合键,将输出的 m:… + c:… 填入配置;如需发送复杂按键序列可用 xte。# 切换/重启 Compton "compton --replace --config ~/.config/compton.conf" m:0x0 + c:37 - 使配置生效:
提示:若需后台常驻,可将 compton 启动为会话服务,再用 xbindkeys 发送 compton --replace 实现切换。killall xbindkeys xbindkeys
生效与排错要点
- 使配置生效
- 修改 i3 配置后执行 Alt+Shift+R 重载;或在终端执行 compton --replace --config ~/.config/compton.conf 立即应用。
- 修改 xbindkeys 配置后需重启 xbindkeys(见上)。
- 配置文件位置与语法
- 常见位置:~/.config/compton.conf、~/.compton.conf、/etc/compton.conf;保存后需重启 Compton 生效。
- 常见为 YAML 格式(示例):
backend: "glx" vsync: true shadow: true opacity: 0.9
- 运行与冲突检查
- 检查 Compton 是否在跑:ps -e | grep compton;若未运行,先启动再绑定切换快捷键。
- 避免与系统/应用快捷键冲突(如 Ctrl+Alt+T 常用于终端)。
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: Compton配置中键盘快捷键怎么设置
本文地址: https://pptw.com/jishu/748264.html
